Centos搭建 使用uwsgi+nginx 配置django

记录这篇文章的前提是,uwsgi的环境,nginx的环境和django框架都已经搭建完毕了。不会的自己可以去google

1,项目创建

sudo django-admin.py startproject walkerfree

2,配置nginx server

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启动设置

[uwsgi]
socket = /tmp/walkerfree.socket
#http=127.0.0.1:9090
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角色)

nginx -s reload
uwsgi --ini /usr/local/etc/uwsgi/walkerfree-uwsgi.ini

5,启动成功

comments powered by Disqus