编辑以尝试第一个答案进行问题排查。
现在我被禁止了403。这就是我所拥有的:
<VirtualHost ip:80>
ServerAdmin admin
ServerName name
WSGIScriptAlias / /home/django/mysite/mysite/wsgi.py
<Directory /home/django/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
我创建了一个用户&#34; django&#34; / home / django和所有子目录都拥有&#34; django&#34;的权限。这是应该的,对吗?
我正在运行django 1.6.2
/ home / django包含mysite,&#39; / home / django / mysite&#39;包含manage.py。 / home / django / mysite / mysite / contains,init,urls和wsgi.py。
wsgi.py包含:
import os
import sys
sys.path.insert(0,'/home/django/mysite')
os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"
# NOTICE: the following may only work well in django version 1.5 1.6
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
我做错了什么?为什么我被禁止? :( wsgi.py需要是用户/组apache吗?
如果重要,服务器版本:Apache / 2.2.15
它可能与mod_userdir.c有关吗?
答案 0 :(得分:3)
我通常使用wsgi.py
mod_wsgi
中撰写
<{1}}中的配置(Apache版本&gt; = 2.4):
*.conf
如果您使用Apache 2.2
<VirtualHost *:80>
ServerName example.com
ServerAdmin example@example.com
Alias /media/ /home/tu/blog/media/
Alias /static/ /home/tu/blog/collected_static/
<Directory /home/tu/blog/media>
Require all granted
</Directory>
<Directory /home/tu/blog/collected_static>
Require all granted
</Directory>
WSGIScriptAlias / /home/tu/blog/blog/wsgi.py
<Directory /home/tu/blog/blog>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
而不是
Order allow,deny
Allow from all
wsgi.py(取决于你的django版本)
Require all granted
也就是说,将您的django项目视为python包,import os
import sys
sys.path.insert(0,'/path/to/project/')
os.environ["DJANGO_SETTINGS_MODULE"] = "project.settings"
# NOTICE: the following may only work well in django version 1.5 1.6
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
用于告诉python项目所在的位置。