apache 在 mod_wsgi 下运行 Django 站点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/302679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running a Django site under mod_wsgi
提问by Gabriel Ross
I am trying to run my Django sites with mod_wsgi instead of mod_python (RHEL 5). I tried this with all my sites, but get the same problem. I configured it the standard way everyone recommends, but requests to the site simply time out.
我正在尝试使用 mod_wsgi 而不是 mod_python (RHEL 5) 运行我的 Django 站点。我在我所有的网站上都试过这个,但遇到同样的问题。我按照每个人推荐的标准方式对其进行了配置,但是对站点的请求只是超时。
Apache conf:
阿帕奇配置:
<VirtualHost 74.54.144.34>
DocumentRoot /wwwclients/thymeandagain
ServerName thymeandagain4corners.com
ServerAlias www.thymeandagain4corners.com
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /var/log/httpd/thymeandagain_access_log combined
ErrorLog /var/log/httpd/thymeandagain_error_log
LogLevel error
WSGIScriptAlias / /wwwclients/thymeandagain/wsgi_handler.py
WSGIDaemonProcess thymeandagain user=admin group=admin processes=1 threads=16
WSGIProcessGroup thymeandagain
</VirtualHost>
wsgi_handler.py:
wsgi_handler.py:
import sys
import os
sys.path.append("/wwwclients")
os.environ['DJANGO_SETTINGS_MODULE'] = 'thymeandagain.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
The daemon mod_wsgi is supposed to spawn off is not there, so requests just time out and I get a bunch of "Unable to connect to WSGI daemon process" errors in the logs. Is there something about the WSGIDaemonProcess directive that is preventing creation of the daemon? Thanks in advance for any help...
守护进程 mod_wsgi 不应该产生,所以请求只是超时,我在日志中收到一堆“无法连接到 WSGI 守护进程”错误。是否有关于 WSGIDaemonProcess 指令阻止创建守护进程的内容?在此先感谢您的帮助...
EDIT: I get this in the error log:
编辑:我在错误日志中得到这个:
[[email protected]] mcm_server_readable():2582: timeout: Operation now in progress: select(2) call timed out for read(2)able fds
[[email protected]] mcm_get_line():1592
[[email protected]] mcm_server_readable():2582: timeout: Operation now in progress: select(2) call timed out for read(2)able fds
[[email protected]] mcm_get_line():1592
[Thu Nov 20 21:18:17 2008] [notice] caught SIGTERM, shutting down
[Thu Nov 20 21:18:18 2008] [notice] Digest: generating secret for digest authentication ...
[Thu Nov 20 21:18:18 2008] [notice] Digest: done
[Thu Nov 20 21:18:18 2008] [notice] mod_python: Creating 4 session mutexes based on 8 max processes and 64 max threads.
[Thu Nov 20 21:18:18 2008] [notice] Apache/2.2.3 (Red Hat) mod_python/3.2.8 Python/2.4.3 mod_wsgi/2.1-BRANCH configured -- resuming normal operations
采纳答案by vvarp
The problem is that mod_python doesn't go well together with mod_wsgi. I got into similar issue few weeks ago and everything started working for me shortly after I commented out mod_python inclusion.
问题是 mod_python 不能很好地与 mod_wsgi 一起使用。几周前我遇到了类似的问题,在我注释掉 mod_python 包含后不久,一切都开始对我来说有效。
Try to search modwsgi.orgwiki for "mod_python", I believe there was someone talking about this somewhere in comments
尝试在modwsgi.orgwiki 中搜索“mod_python”,我相信有人在评论中讨论过这个问题
回答by Graham Dumpleton
The real problem is permissions on Apache log directory. It is necessary to tell Apache/mod_wsgi to use an alternate location for the UNIX sockets used to communicate with the daemon processes. See:
真正的问题是对 Apache 日志目录的权限。有必要告诉 Apache/mod_wsgi 为用于与守护进程通信的 UNIX 套接字使用备用位置。看:
http://code.google.com/p/modwsgi/wiki/ConfigurationIssues#Location_Of_UNIX_Sockets
http://code.google.com/p/modwsgi/wiki/ConfigurationIssues#Location_Of_UNIX_Sockets

