Django - permission denied

时光总嘲笑我的痴心妄想 提交于 2019-12-12 19:14:37

问题


I'm trying to setup Django (Django 1.9.6) on Apache (Apache 2.4.10) in my vps (ubuntu server 15.04).

I followed this guide: HERE

Unfortunately when I try to visit my website, the server return this error (403 Forbidden):`

[authz_core:error]  AH01630: client denied by server configuration: /home/user/proj/proj/wsgi.py

I searched everywhere for a solution but everything I tried didn't work.

this is my /etc/apache2/sites-available/000-default.conf file:

    Alias /static /home/user/proj/Gestione/static
    <Directory /home/user/proj/Gestione/static>
        Order deny,allow
        Allow from all
    </Directory>

    <Directory /home/user/proj/proj>
        <Files wsgi.py>
            Order deny,allow
            Allow from all
        </Files>
    </Directory>
    WSGIDaemonProcess proj python-path=/home/user/proj:/home/user/.local/lib/python3.4/site-p$
    WSGIProcessGroup proj
    WSGIScriptAlias / /home/user/proj/proj/wsgi.py

Then i found this code on /etc/apache2/apache2.conf, I don't know if this could create problems:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

This is my wsgy.py:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
application = get_wsgi_application()

I'm NOT using virtualenv

Thanks for help


回答1:


In Apache 2.4, you should use Require all granted instead of Order deny,allow and Allow from all.

It looks like you are using the old style in two places in 000-default.conf. Try updating it to:

<Directory /home/user/proj/Gestione/static>
    Require all granted
</Directory>

<Directory /home/user/proj/proj>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>


来源:https://stackoverflow.com/questions/37238192/django-permission-denied

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