403 Forbidden error with Django and mod_wsgi

半城伤御伤魂 提交于 2019-11-27 21:04:15

Apparently this is an issue that is related to Apache 2.4 and older versions. You need to replace in your apache configuration:

Allow from all

with

Require all granted

in the <Files wsgi.py> section

You can use the following:

<Directory /home/aettool/aet/apache>
  <IfVersion < 2.3 >
   Order allow,deny
   Allow from all
  </IfVersion>
  <IfVersion >= 2.3>
   Require all granted
  </IfVersion>
</Directory>
erajuan

This has been reported in Django ticket 19319:

https://code.djangoproject.com/ticket/19319

Your Apache config now needs the following for your file wsgi.py.

<Directory /path/to/your/wsgi-script>
<Files wsgi.py>
  Order deny,allow
  Allow from all
  Require all granted
</Files>
</Directory>

There is one other gotcha:

Check your httpd.conf file for the following configuration:

<IfModule mime_module>
      AddHandler cgi-script .cgi .pl .py
</IfModule>

This will cause the error.

.py MUST NOT be configured as a CGI script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!