所以我尝试使用apache 2.2
和mod_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
?
答案 0 :(得分:1)
所以在抓了我的头之后,我想我会看看更有帮助的apache错误日志。似乎我的Directory
和Files
标记的值不正确。
这对我有用:
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>