uwsgi安装
pip install uwsgi
编写配置文件
[uwsgi] master = true processes = 1 threads = 2 socket = 127.0.0.1:3031 chmod-socket = 660 vacuum = true max-requests = 1000 chdir = /data/wwwroot/project wsgi-file = /data/wwwroot/project/demo/wsgi.py daemonize = /data/wwwroot/project/logs/uwsgi.log req-logger = file:/data/wwwroot/project/logs/reqlog.log logger = file:/data/wwwroot/project/logs/errlog.log
nginx代理配置
location / { include uwsgi_params; uwsgi_pass 127.0.0.1:3031; uwsgi_param X-Real-IP $remote_addr; uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for; uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto; proxy_set_headerHost $host; proxy_set_headerX-Real-IP $remote_addr; proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_headerREMOTE-HOST $remote_addr; add_headerX-Cache $upstream_cache_status; add_headerCache-Controlno-cache; add_headerAccess-Control-Allow-Origin *; }
启动脚本
uwsgi --ini /data/wwwroot/project/uwsgi.ini
- uwsgi可以直接用作web服务器,这里使用的是用nginx作代理服务器的配置
- uwsgi一般常用于python项目中的web服务