0.基本配置
/path/to/mysite.com/是项目路径。替换成实际的就好了。
1 2 3 4 5 6 7 8
| WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py WSGIPythonPath /path/to/mysite.com <Directory /path/to/mysite.com/mysite> <Files wsgi.py> Require all granted </Files> </Directory>
|
另外如果你用apache2.2,那么需要改Require语法。
1 2 3 4
| <Files wsgi.py> Allow from all Order deny,allow </Files>
|
1.静态文件
在setting.py文件中定义STATIC_ROOT
1
| STATIC_ROOT = "/var/www/example.com/static/"
|
生成静态文件
1
| python manage.py collectstatic
|
然后用apache的Alias就可以了。
1 2
| Alias /media/ /path/to/mysite.com/media/ Alias /static/ /path/to/mysite.com/static/
|