阿帕奇mod_wsgi的错误:紫禁城您没有权限访问/在此服务器上 [英] Apache mod_wsgi error: Forbidden You don't have permission to access / on this server

查看:239
本文介绍了阿帕奇mod_wsgi的错误:紫禁城您没有权限访问/在此服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Ubuntu 10.04。结果
我下创建一个Django项目 /家庭/ wong2 / code /蟒蛇/ django2 / 名为 ATEST

并建立在同一目录下搜索一个WSGI文件 setting.wsgi
这里的内容 setting.wsgi

I'm using Ubuntu 10.04.
I create a django project under /home/wong2/Code/python/django2/ named atest
and create a wsgi file setting.wsgi in the same directory
Here is the content of setting.wsgi :

import os 
import sys

path = '/home/wong2/Code/python/django2'

if path not in sys.path:
    sys.path.append(path)
os.environ["DJANGO_SETTINGS_MODULE"] = "atest.settings" 
from django.core.handlers.wsgi import WSGIHandler 
application = WSGIHandler()

和这里是我添加到我的我的httpd.conf:

and here is what I add to my my httpd.conf:

<VirtualHost *:80>
    ServerName localhost
    WSGIScriptAlias / /home/wong2/Code/python/django2/setting.wsgi
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow  
        Allow from all 
    </Directory>
    <Directory "/home/wong2/Code/python/django2/atest">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

问题是,当我访问的http://本地主机,它说:

禁止

您没有权限访问/
  此服务器上。

You don't have permission to access / on this server.

非常感谢。

推荐答案

第二个目录块不匹配,你必须安装在您的WSGI脚本文件。这是实践中非常糟糕,虽然粘WSGI脚本文件在源$ C ​​$ C或其他敏感文件存在的位置,也就是说,同一个目录或子目录。相反,你应该在自己的子目录坚持下去。因此:

The second directory block doesn't match where you have your WSGI script file installed. It is very bad practice though to stick the WSGI script file in a location where source code or other sensitive files exist, ie., same directory or sub directory. Instead you should stick it in a sub directory of its own. Thus:

WSGIScriptAlias / /home/wong2/Code/python/django2/atest/apache/setting.wsgi
<Directory "/home/wong2/Code/python/django2/atest/apache">
    Order allow,deny
    Allow from all
</Directory>

所以,下创建ATEST'阿帕奇'子目录。移动'setting.wsgi'成'阿帕奇'子目录和变更配置上面。

So, create 'apache' subdirectory under 'atest'. Move 'setting.wsgi' into that 'apache' subdirectory and change config to above.

您问题也可能通过在你的主目录为Apache的限制性permisions造成的看不到里面。

Your problem also may be caused by restrictive permisions on your home directory as Apache cannot see inside.

前去观看:

<一个href=\"http://$c$c.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_$p$psentations\">http://$c$c.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_$p$psentations

,因为它解释了这些权限问题,以及像在哪里坚持你的code和WSGI脚本文件的问题。

as it explains these permissions problems as well as issues like where to stick your code and the WSGI script file.

另请阅读:

<一个href=\"http://$c$c.google.com/p/modwsgi/wiki/IntegrationWithDjango\">http://$c$c.google.com/p/modwsgi/wiki/IntegrationWithDjango

这篇关于阿帕奇mod_wsgi的错误:紫禁城您没有权限访问/在此服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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