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:3031
chdir=/root/project/seth_stack/
wsgi-file=seth_stack/wsgi.py
processes=4
threads=2
stats=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.py
processes=4 #根据需要配置
threads=2
stats=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 {
}
}