django - 无法使用Cpanel/WHM连接到Centos7中的WSGI守护程序进程mod_wsgi

标签 django apache sockets mod-wsgi whm

我在使用Django和WHM在VPS中部署Centos 7.3时遇到问题。除了mod_wsgi的套接字问题外,它似乎可以工作。

[Sun Jun 25 00:37:03.254774 2017] [wsgi:error] [pid 29756] (13)Permission denied: [client 66.249.83.220:35523] mod_wsgi (pid=29756): Unable to connect to WSGI daemon process 'brunamaiahair.com.br' on '/var/run/apache2/wsgi.721.27.1.sock' as user with uid=1004.

我读过将插入WSGISocketPrefix 作为指令,因此我编辑了httpd.conf并放入:
WSGISocketPrefix /var/run/apache2/wsgi

但是我收到了同样的错误。这是Apache重新启动后修改后的httpd.conf的日志:
[Sat Jun 24 21:10:56.084269 2017] [mpm_prefork:notice] [pid 721] AH00163: Apache/2.4.25 (cPanel) OpenSSL/1.0.2k mod_bwlimited/1.4 mod_wsgi/4.5.7 Python/2.7 configured -- resuming normal operations

这是我的VirtualHost配置:
WSGIDaemonProcess brunamaiahair.com.br socket-user=#1004 python-path=/home/bmhair/public_html/django/framework:/home/bmhair/public_html/django/denv/lib/python2.7/site-packages

WSGIProcessGroup brunamaiahair.com.br

WSGIScriptAlias / /home/bmhair/public_html/django/framework/framework/wsgi.py

最佳答案

请参阅以下内容中的socket-user选项:

  • http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html

  • 最近安装的CPanel似乎使用PrivilegesMode设置为SECURE,因此您需要声明谁应该拥有套接字。应该是在为您处理请求时Apache更改为用户/uid,而不是Apache用户的默认用户/uid。

    例如,如果设置为在Apache下运行您的请求的CPanel的用户是bmhair,那么您需要在Apache配置中的WSGIDaemonProcess指令中添加以下选项:
    socket-user=bmhair
    

    重新启动Apache之后,请检查放置套接字文件的目录(例如/var/run/apache2),并检查套接字文件是否由bmhair用户拥有。

    请注意,这将要求目录/var/run/apache2提供对其他用户的访问权限,即,不仅仅是root或Apache用户以您的身份运行您的代码。如果不是这种情况,请使用WSGISocketPrefix将套接字文件移动到用户bmhair可以访问的另一个目录。通常,您甚至不需要覆盖WSGISocketPrefix,因为使用的默认位置很好。如果您出于某些原因明确设置了该设置,并且不允许使用默认设置,那也可能是问题的一部分。

    关于django - 无法使用Cpanel/WHM连接到Centos7中的WSGI守护程序进程mod_wsgi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44743472/

    相关文章:

    PHP代码没有被执行,但是代码显示在浏览器源代码中

    c++ - 什么会导致我的数据包的字节顺序变得部分困惑?

    django - 覆盖 Django 模型中的深度复制

    django - 切换 CMS 的工具和技巧

    django - 如何访问 Django 的 field.choices?

    python - 如何获取 google Drive sdk 的 python-social-auth 凭据?

    Apache Nutch 2.1 不同批处理 ID(空)

    php - Apache 服务器上的 Centos 配置 php

    java - 在 IRC 聊天室中发送大型 ASCII 作为 UTF-8 消息时连接重置

    c++ - 管理多个 UDP 套接字的超时