Django Apache DocumentRoot?

时间:2017-05-12 22:27:31

标签: django apache document-root

Apache中的DocumentRoot必须设置为运行Django应用程序的目录是静态目录但是不起作用?感谢所有人提前帮助。

1 个答案:

答案 0 :(得分:2)

你指向项目根; wsgi.py文件所在的位置。来自documentation

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonHome /path/to/venv
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

静态文件是单独配置的。详情here。示例(同样,来自docs):

Alias /robots.txt /path/to/mysite.com/static/robots.txt
Alias /favicon.ico /path/to/mysite.com/static/favicon.ico

Alias /media/ /path/to/mysite.com/media/
Alias /static/ /path/to/mysite.com/static/

<Directory /path/to/mysite.com/static>
Require all granted
</Directory>

<Directory /path/to/mysite.com/media>
Require all granted
</Directory>

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>