在mod_wsgi下运行Django网站

9
我将尝试使用mod_wsgi而不是mod_python(RHEL 5)来运行我的Django网站。我已经在所有的网站上都尝试了这个,但遇到了同样的问题。我按照大家推荐的标准方法进行了配置,但对该网站的请求却一直超时。
Apache配置文件:
<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:

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()

守护进程mod_wsgi应该创建的守护进程不存在,因此请求超时并且日志中出现了大量“无法连接到WSGI守护进程进程”的错误。是否有关于WSGIDaemonProcess指令阻止守护进程创建的问题?感谢您提前提供任何帮助...

编辑:我在错误日志中看到了这个:

[WARN@1227228322.174175] mcm_server_readable():2582: timeout: Operation now in progress: select(2) call timed out for read(2)able fds
[INFO@1227228322.174263] mcm_get_line():1592
[WARN@1227227903.249626] mcm_server_readable():2582: timeout: Operation now in progress: select(2) call timed out for read(2)able fds
[INFO@1227227903.249712] 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

服务器的错误日志里有什么吗?如果WSGI守护进程启动时出现问题,我认为日志会告诉你。 - Powerlord
这解决了我的问题:http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html - Lakshman Srikanth D
3个回答

10

这正是我的问题所在; 我使用基本未更改的httpd.conf运行CentOS 6,没有加载mod_python(就像另一个答案建议的那样),但配置WSGISocketPrefix和适当的套接字目录权限解决了它! - mjjohnson
1
这也是我的问题。我正在运行RHEL6,并将WSGISocketPrefix /var/run/wsgi添加到httpd.conf中解决了它。 - Nifle

4
问题在于mod_python和mod_wsgi不兼容。几周前我遇到了类似的问题,在我注释掉mod_python包含之后,一切开始正常工作。
尝试在modwsgi.org wiki中搜索“mod_python”,我相信有人在评论中谈到了这个问题。

1

这里有非常详细的说明,介绍如何将Django与mod_wsgi集成。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接