您的位置:首页 > 运维架构 > Apache

django static + apache mod_wsgi部署

2016-05-16 16:46 489 查看

0.基本配置

/path/to/mysite.com/是项目路径。替换成实际的就好了。

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语法。

<Files wsgi.py>
Allow from all
Order deny,allow
</Files>


1.静态文件

在setting.py文件中定义STATIC_ROOT

STATIC_ROOT = "/var/www/example.com/static/"


生成静态文件

python manage.py collectstatic


然后用apache的Alias就可以了。

Alias /media/ /path/to/mysite.com/media/
Alias /static/ /path/to/mysite.com/static/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: