正确配置django站点的httpd.conf

时间:2016-07-06 17:41:16

标签: django apache wamp windows-10 mod-wsgi

所以我尝试使用apache 2.2mod_wsgi部署我的django项目。我已经到了为httpd.conf配置apache文件的问题,但我想我可能做错了,因为我在尝试访问我的网站时不断获得"403: You don't have permission to access / on this server."。{{ 3}}

这就是我的项目结构:

"C:\wamp2.2\ums" 
myapp/
    pm_app/
        __init__.py
        settings.py
        urls.py
        wsgi.py

    ums/
        static/..
        templates/..
        __init__.py
        admin.py
        models.py
        views.py
    manage.py
    requirements.txt

pm_app包含wsgi.py文件,而ums是包含网站的文件夹

wsgi.py:

import os, sys

sys.path.append('C:/wamp2.2/ums')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pm_app.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

的httpd.conf:

WSGIPythonPath "C:/wamp2.2/ums"
WSGIScriptAlias / "C:/wamp2.2/ums/pm_app"

<Directory "C:/wamp2.2/ums/ums">
<Files wsgi.py>
    Order deny,allow
    Allow from all
</Files>
</Directory>

我的路径错了,或者我错过了什么。我是否也通过localhost正确访问了网站,或者应该是localhost/ums

1 个答案:

答案 0 :(得分:1)

所以在抓了我的头之后,我想我会看看更有帮助的apache错误日志。似乎我的DirectoryFiles标记的值不正确。

这对我有用:

WSGIScriptAlias / "C:/wamp2.2/ums/pm_app/wsgi.py"
WSGIPythonPath "C:/wamp2.2/ums/env/Lib/site-packages";"C:/wamp2.2/ums/pm_app"

<Directory "C:/wamp2.2/ums/pm_app">
    <Files "wsgi.py">
      Order deny,allow
      Allow from all
    </Files>
</Directory>