带有 mod_wsgi 的 Django 返回 403 错误 [英] Django with mod_wsgi returns 403 error
问题描述
我正在尝试将 Django 与 Apache(和 mod_wsgi)一起使用.使用默认的 Django 网络服务器一切顺利,但现在我在尝试加载页面时收到 403(禁止访问)错误.我在这里搜索了以前的帖子并阅读了官方文档,但那里的解决方案没有帮助.
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.
这是我的 httpd.conf 中的几行:
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>
权限设置为 770,并为/home/karlis/django 下的所有文件夹设置了粘性位.我有 django 1.2.3、mod_wsgi 3.2、apache 2.2.15 并且我运行 Arch Linux.
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.
我在这里做错了什么?
提前致谢!-skazhy
Thanks in advance! -skazhy
推荐答案
还有一个问题:
检查您的 httpd.conf 文件中的以下配置:
Check your httpd.conf file for the following configuration:
<IfModule mime_module>
AddHandler cgi-script .cgi .pl .py
</IfModule>
这会导致错误.
.py 不得配置为 CGI 脚本
.py MUST NOT be configured as a CGI script
这篇关于带有 mod_wsgi 的 Django 返回 403 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!