带有 mod_wsgi 的 Django 返回 403 错误
我正在尝试将 Django 与 Apache(和 mod_wsgi)一起使用。使用默认的 Django Web 服务器,一切进展顺利,但现在在尝试加载页面时出现 403(访问禁止)错误。我在这里搜索了以前的帖子并阅读了官方文档,但那里的解决方案没有帮助。
以下是我的 httpd.conf 中的几行:
WSGIScriptAlias / /home/karlis/django/apache/django.wsgi
<Directory /home/karlis/django/apache>
Order allow,deny
Allow from all
</Directory>
Alias /media/ /home/karlis/django/media
<Directory /home/karlis/django/media>
Order deny,allow
Allow from all
</Directory>
权限设置为 770,并且 /home/karlis/django 下的所有文件夹都设置了粘性位。我有 django 1.2.3、mod_wsgi 3.2、apache 2.2.15,我运行 Arch Linux。
我在这里做错了什么?
提前致谢! -斯卡日
I am trying to use Django with Apache (and mod_wsgi). With the default Django webserver everything was going well, but now I get 403 (access forbidden) error when trying to load the page. I searched previous posts here and read official docs but the solutions there weren't helpful.
Here are the lines from my httpd.conf:
WSGIScriptAlias / /home/karlis/django/apache/django.wsgi
<Directory /home/karlis/django/apache>
Order allow,deny
Allow from all
</Directory>
Alias /media/ /home/karlis/django/media
<Directory /home/karlis/django/media>
Order deny,allow
Allow from all
</Directory>
Permissions are set to 770 and there is sticky bit set to all folders under /home/karlis/django. I have django 1.2.3, mod_wsgi 3.2, apache 2.2.15 and I run Arch Linux.
What I am doing wrong here?
Thanks in advance!
-skazhy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Apache 作为特殊用户运行,它将无法读取权限为 770 的内容。
观看演讲:
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations
解释了有关权限的内容。
解决问题的关键是 Apache 错误日志中出现的错误消息。您甚至没有说明在日志文件中收到的错误消息。链接的演讲展示了这些错误消息可能是什么以及它们的含义。
Apache runs as a special user, it will not be able to read stuff with permissions of 770.
Watch the talk at:
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations
which explains things about permissions.
The key for working out the problem is what error message appears in your Apache error log. You do not even state what error messages you get in the log file. The talk linked to shows what those error messages might be and what they mean.
还有另外一个问题:
检查 httpd.conf 文件中的以下配置:
这将导致错误。
.py 不得配置为 CGI 脚本
There is one other gotcha:
Check your httpd.conf file for the following configuration:
This will cause the error.
.py MUST NOT be configured as a CGI script
试试这个而不是你的目录语句:
Try this instead your directories statements: