Django - 被拒绝的权限 [英] Django - permission denied

查看:207
本文介绍了Django - 被拒绝的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的vps(ubuntu服务器15.04)中的Apache(Apache 2.4.10)上设置Django(Django 1.9.6)。



我跟着本指南: HERE



不幸的是,当我尝试访问我的网站时,服务器返回此错误(403 Forbidden):`

  [authz_core:error] AH01630:客户端被服务器配置拒绝:/home/user/proj/proj/wsgi.py 

我在任何地方搜索了一个解决方案,但是我尝试的一切都无效。



这是我的/etc/apache2/sites-available/000-default.conf文件:

 别名/静态/首页/ user / proj / Gestione / static 
< Directory / home / user / proj / Gestione / static>
订单拒绝,允许
允许从所有
< / Directory>

< Directory / home / user / proj / proj>
<文件wsgi.py>
订单拒绝,允许
允许从所有
< / 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

然后我发现这个代码在/ etc / apache2 / apache2 .conf,我不知道这是否会造成问题:

 < Directory /> 
选项FollowSymLinks
AllowOverride无
要求所有被拒绝
< / Directory>

这是我的wsgy.py:

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

我没有使用virtualenv



感谢您的帮助

解决方案

在Apache 2.4中,您应该使用要求所有授予的而不是订单拒绝,允许允许从所有



看起来您在 000-default.conf 中的两个地方使用旧样式。尝试更新为:

 < Directory / home / user / proj / Gestione / static> 
要求全部授予
< / Directory>

< Directory / home / user / proj / proj>
<文件wsgi.py>
要求全部授予
< / Files>
< / Directory>


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

解决方案

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>

这篇关于Django - 被拒绝的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆