403 Forbidden error with Django and mod_wsgi

前端 未结 5 809
梦谈多话
梦谈多话 2020-12-09 07:52

I created Django project in home directory so it is in home directory.

Setup

Django Verison  : 1.5.1
Python Version  : 2.7.5
mod_wsg         


        
相关标签:
5条回答
  • 2020-12-09 08:33

    Linux systems usually don't allow other users to read inside the home directory, and as Apache runs as root, mod_wsgi will not be able to access the inside of the home directory. Try:

    sudo chmod 755 /home/<username>
    
    0 讨论(0)
  • 2020-12-09 08:34

    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>
    
    0 讨论(0)
  • 2020-12-09 08:38

    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

    0 讨论(0)
  • 2020-12-09 08:53

    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>
    
    0 讨论(0)
  • 2020-12-09 08:56

    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

    0 讨论(0)
提交回复
热议问题