django项目的nginx和gunicorn

时间:2013-08-02 12:12:47

标签: django nginx

大家好,我是django的新手,所有的好东西都不知道如何用dginx和gunicorn为django项目设置这样的东西谢谢

虚拟主机1

<VirtualHost *:80>
ServerName project1.com
ServerAlias www.project1.com
ServerAdmin info@project1.com

Alias /static/ /path/to/project1/project1/static/
Alias /media/ /path/to/project1/project1/media/

ErrorLog   /path/to/project1/error.log
CustomLog /path/to/project1/access.log combined

WSGIDaemonProcess project1.com processes=2 threads=15 display-name=%{GROUP} python-path=/path/to/project1:/path/to/project1/local/lib/python2.7/site-packages
WSGIProcessGroup project1.com

WsgiScriptAlias / /path/to/project1/project1/wsgi.py

<Directory /path/to/project1/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

虚拟主机2

<VirtualHost *:80>
ServerName project2.com
ServerAlias www.project2.com
ServerAdmin info@project2.com

Alias /static/ /path/to/project2/project2/static/
Alias /media/ /path/to/project2/project2/media/

ErrorLog   /path/to/project2/error.log
CustomLog /path/to/project2/access.log combined

WSGIDaemonProcess project2.com processes=2 threads=15 display-name=%{GROUP} python-path=/path/to/project2:/path/to/project2/local/lib/python2.7/site-packages
WSGIProcessGroup project2.com

WsgiScriptAlias / /path/to/project2/project2/wsgi.py

<Directory /path/to/project2/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

1 个答案:

答案 0 :(得分:2)

看看http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/ - 这应该足以让你开始使用nginx和gunicorn。