【发布时间】:2012-03-02 02:06:58
【问题描述】:
我知道这个问题被问了数百万次,但我已经花了很多时间尝试在 CentOS 5.7 上配置 Apache 和 mod_wsgi,这对我来说是新的。在 Debian (Ubuntu) 上从来没有遇到过这种问题。
我在/etc/httpd/conf.d/ 目录中创建了wsgi.conf,包含以下几行:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /var/xxx/env
/var/xxx/env 包含项目的虚拟环境。
然后我在/etc/httpd/conf.d/ssl.conf 中添加了以下几行(是的,我需要它用于 https,但我也尝试将其放入普通虚拟主机中)。
WSGIScriptAlias /suburl /var/xxx/yyy/hello.wsgi
<Location /suburl>
Order deny,allow
Allow from all
</Location>
hello.wsgi 包含
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
这是ls -l /var/xxx/的输出
total 16
drwxr-xr-x 5 apache apache 4096 Feb 9 05:14 env
drwxr-xr-x 7 apache apache 4096 Feb 9 05:41 yyy
ls -l /var/xxx/yyy/的输出
total ...
...
-rwxr-xr-x 1 apache apache 238 Feb 9 05:19 hello.wsgi
...
ps -Af | grep httpd 显示
root 8872 1 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8874 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8875 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8876 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8877 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8878 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8879 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8880 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
apache 8881 8872 0 07:06 ? 00:00:00 /usr/sbin/httpd
fedor 10609 4716 0 07:16 pts/1 00:00:00 grep httpd
/var/log/httpd/ssl_error_log 充满了如下几行
[Thu Feb 09 07:06:47 2012] [error] [client 127.0.0.1] (13)Permission denied: access to /suburl denied
但它通过调用 sudo /usr/sbin/httpd hello.wsgi 启动 Apache 开始工作,即使 ps -Af | grep httpd 显示非常相似的行:
root 11442 1 3 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11443 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11444 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11445 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11446 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11447 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11448 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11449 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
apache 11450 11442 0 07:21 ? 00:00:00 /usr/sbin/httpd
fedor 11453 4716 0 07:21 pts/1 00:00:00 grep httpd
任何可能导致问题的想法以及我还需要检查什么?
【问题讨论】:
标签: python apache centos mod-wsgi wsgi