【发布时间】:2014-02-02 13:22:33
【问题描述】:
我正在尝试使用 apache (2.2.22) 和 mod_wsgi (3.4) 运行 django (1.6) 项目。我的python是2.7.3,ubuntu 12.04默认。我已将所有内容设置为 chmod 777 从 /var/www 到向下。不幸的是它给了我
打开文件读取时出错:权限被拒绝 然后 脚本头过早结束:wsgi.py
谁能告诉我我做错了什么? 我在这里发布我的error.log
root@whq-4:/var/www/Imse_dev2/Imse/Imse# tail -f /var/log/apache2/error.log
[Tue Jan 14 14:16:04 2014] [notice] caught SIGTERM, shutting down
[Tue Jan 14 14:16:08 2014] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations
[Tue Jan 14 14:16:28 2014] [error] /var/www/Imse_dev2/Imse
Error opening file for reading: Permission denied
[Tue Jan 14 14:21:32 2014] [error] [client 127.0.0.1] Premature end of script headers: wsgi.py
[Tue Jan 14 14:29:13 2014] [notice] caught SIGTERM, shutting down
[Tue Jan 14 14:29:13 2014] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations
[Tue Jan 14 14:29:17 2014] [error] /var/www/Imse_dev2/Imse
Error opening file for reading: Permission denied
[Tue Jan 14 14:34:21 2014] [error] [client 127.0.0.1] Premature end of script headers: wsgi.py
还有我的 httpd.conf 文件
#LimitRequestLine 200475
#LimitRequestFieldSize 200475
WSGIDaemonProcess imse_dev2_wsgi python-path=/var/www/Imse_dev2/Imse/Imse
#LoadModule deflate_module modules/mod_deflate.so
#LoadModule headers_module modules/mod_headers.so
<VirtualHost *:80>
ServerName whq-4
DocumentRoot /var/www/
#Header set Access-Control-Allow-Origin "*"
Alias /static /var/www/Imse_dev2/Imse/static
Alias /favicon.ico /var/www/favicon.ico
# Header set Access-Control-Allow-Origin "*"
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
WSGIScriptAlias /imse_dev2 /var/www/Imse_dev2/Imse/Imse/wsgi.py
<Directory /var/www/Imse_dev2/Imse/Imse>
WSGIProcessGroup imse_dev2_wsgi
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</VirtualHost>
【问题讨论】:
-
我认为对于 apache 2.2 你应该使用 mod_wsgi 3.3
-
好的,那我试试……
-
完全不知道,这可能是一个微不足道的问题,但我很挣扎
-
我找了很多但还是没有解决,apache2无论如何都无法访问我项目的根目录
-
不知道是不是这样,但我注意到您在
<Directory>中有/var/www/Imse_dev2/Imse/Imse,但错误是针对/var/www/Imse_dev2/Imse(少一个Imse)。如果第一个路径是正确的,那么它可能不应该尝试将/var/www/Imse_dev2/Imse作为文件打开,因为它似乎是一个目录。