教程来自Python uWSGI 安装配置Python/WSGI应用快速入门
uwsgi --http :9090 --wsgi-file foobar.pyapt install uwsgi安装的uwsgi会有这样的问题
uwsgi: option '--http' is ambiguous; possibilities: '--http-socket' '--http-socket-modifier1' '--http-socket-modifier2' '--http11-socket' '--https-socket' '--https-socket-modifier1' '--https-socket-modifier2'
getopt_long() error换成--http-socket
uwsgi --http-socket :9090 --wsgi-file foobar.pyuwsgi: unrecognized option '--wsgi-file'
getopt_long() error加上--plugin python
uwsgi --http-socket :9090 --plugin python --wsgi-file foobar.py当使用发行版提供的包来测试这个快速入门时,你也许想要考虑一件事,就是非常有可能你的发行版本以模块化的方式构建了uWSGI (每个特性都是一个必须加载的不同插件)。要完成这个快速入门,你必须在第一个系列的例子前面加上 --plugin python,httphttps://stackoverflow.com/questions/35460816/uwsgi-http-is-ambiguous
uwsgi --plugins http,python --http :9090 --wsgi-file foobar.py这样就也可以了
uwsgi --plugins http,python3 --http :9090 --wsgi-file foobar.pylocation / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}uwsgi --socket 127.0.0.1:3031 --wsgi-file foobar.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191这个搭配上面的nginx配置是可行的
下面这条,就出问题了
uwsgi_proto_http_parser() -> client closed connection
看了这篇[uWSGI 踩坑记](https://www.cnblogs.com/xueweihan/p/9060065.html)
uwsgi --http-socket 127.0.0.1:3031 --wsgi-file foobar.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:3031;
}改成这样就可以了
配置文件是在/etc/nginx/sites-enabled/default里
#location / {
# # First attempt to serve request as file, then
# # as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
#}
#通过 uwsgi 协议传递请求
#location / {
# include uwsgi_params;
# uwsgi_pass 127.0.0.1:3031;
#}
#通过 http 协议传递请求
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:3031;
}