uwsgi+django+nginx部署

来源:互联网 发布:淘宝照片怎么拍才好看 编辑:程序博客网 时间:2024/05/04 02:53

uwsgi官方教程:http://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html
nginx官方教程:http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html

vim /etc/uwsgi.ini

[uwsgi]socket=127.0.0.1:3031chdir=/root/project/seth_stack/wsgi-file=seth_stack/wsgi.pyprocesses=4threads=2stats=127.0.0.1:9191

但是测试有问题
经百度需要安装uwsgi-plugin-python

yum install uwsgi-plugin-python

而且配置文件需要加一行

plugins = python

因为我是yum install uwsgi安装的
所以这里没有使用supervisor

最后配置文件为

[uwsgi]socket=127.0.0.1:3031 #nginx那边的uwsgi_pass地址chdir=/root/project/seth_stack/ #项目根路径wsgi-file=myproject/wsgi.py #项目路径下面的主app下面的wsgi.pyprocesses=4  #根据需要配置threads=2stats=127.0.0.1:9191 #监控状态的,可以不配置

顺便贴下nginx的server

server {        listen       80 default_server;        listen       [::]:80 default_server; #ipv6可以删掉        server_name  _;        root         /usr/share/nginx/html;#这个root无所谓        include /etc/nginx/default.d/*.conf;        #资源目录        location ^~ /assets/ {            root /opt/;        }        访问uwsgi        location / {            uwsgi_pass 127.0.0.1:9000;            include uwsgi_params;        }        #错误页随便配置        error_page 404 /404.html;            location = /40x.html {        }        error_page 500 502 503 504 /50x.html;            location = /50x.html {        }    }
0 0
原创粉丝点击