Django on apache wtih mod_wsgi (Linux) - 403 Forbidden

后端 未结 3 1239
轻奢々
轻奢々 2021-01-19 04:37

Alright, so i am following this tutorial. When i try to access my site through my local server i get this peculiar error:

Forbidden You don\'t have per

相关标签:
3条回答
  • 2021-01-19 05:01

    If this is exactly your config file then i doubt the path that you're using is wrong. Please fix that first.

    Set WSGIScriptAlias this to correct path.

    Then your WSGI file must look something like:

    import os
    import sys
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
    
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
    
    0 讨论(0)
  • 2021-01-19 05:02

    A things to start with:

    WSGIScriptAlias / /home/nick/Mysite/mysite.wsgi
    

    For this, you do not have a corresponding:

    <Directory/home/nick/Mysite>
    <Files mysite.wsgi>
    Require all granted
    </Files>
    </Directory>
    

    Also, a home directory such as /home/nick is usually not readable to other users and so Apache wouldn't be able to read stuff in that directory anyway.

    Next is:

    Alias /static /var/www/mysite/static/
    

    You shouldn't have a trailing slash on final path. Not having them matched when for a sub URL can cause issues, although usually when the trailing slash is on the URL and missing for the file system path. Better just to have them match as far as whether a trailing slash is used or not.

    0 讨论(0)
  • 2021-01-19 05:07

    I had the same problem.

    your .wsgi script should be located in the /var/www/mysite/ folder and then your config files should be adjusted as necessary.

    Also delete the leading / in :

    .. Alias /static /var/www/mysite/static ..

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