Centos搭建 使用uwsgi+nginx 配置django

{app.params.name}} {app.params.name}} {app.params.name}}

记录这篇文章的前提是,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,启动成功


版权声明

davidzhang 创作并维护的 Gowhich 博客采用 创作共用保留署名-非商业-禁止演绎4.0国际许可证。

本文首发于 Gowhich 博客( https://www.gowhich.com ),版权所有,侵权必究。

本文永久链接: https://www.gowhich.com/blog/322

comments powered by Disqus