记录这篇文章的前提是,uwsgi的环境,nginx的环境和django框架都已经搭建完毕了。不会的自己可以去google
1,项目创建
1
| sudo django-admin.py startproject walkerfree
|
2,配置nginx server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| server { listen 80; server_name www.walkerfree.com; index index.html index.htm default.html default.htm; root /home/wwwroot/walkerfree/walkerfree;
access_log /home/wwwlogs/www.walkerfree.access.log; error_log /home/wwwlogs/www.walkerfree.error.log;
location / { include uwsgi_params; uwsgi_pass unix://tmp/walkerfree.socket; }
location ^~ /static/ { root /home/wwwroot/walkerfree/; }
location ~ ^.+\.(gif|jpg|png|ico|jpeg)$ { expires 3d; }
location ~ ^.+\.(css|js)$ { expires 12h; } }
|
3,配置项目的uwsgi启动设置
1 2 3 4 5 6 7 8 9 10
| [uwsgi] socket = /tmp/walkerfree.socket
chdir=/home/wwwroot/walkerfree module=walkerfree.wsgi master=True pidfile=/tmp/uwsgi.pid vacuum=True max-requests=5000 daemonize=/home/wwwlogs/walkerfree-uwsgi.log
|
4,启动uwsgi,启动nginx(root角色)
1 2
| nginx -s reload uwsgi --ini /usr/local/etc/uwsgi/walkerfree-uwsgi.ini
|
5,启动成功