1

大家好,我是 django 的新手,它的所有好东西都不想知道如何使用 nginx 和 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>
4

1 回答 1

2

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

于 2013-08-05T09:18:48.547 回答