尝试在 Ubuntu 13.10 上设置 Nginx 和 uWSGI。
当我尝试访问该网站时,我得到的只是“502 Bad Gateway”。
运行 apt-get install nginx uwsgi uwsgi-plugin-python3
来安装 nginx/uwsgi。
/etc/nginx/sites-enabled/webpage.com:
server {
listen 80;
server_name webpage.com;
access_log /var/log/nginx/webpage.com_access.log;
error_log /var/log/nginx/webpage.com_error.log;
location / {
uwsgi_pass /var/run/webpage.com.uwsgi.socket;
include uwsgi_params;
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}
}
/etc/uwsgi/apps-enabled/webpage.com
[uwsgi]
vhost = true
plugin = python3
socket = /tmp/webpage.com.sock
master = true
enable-threads = true
processes = 2
home = /var/www/webpage.com/env
wsgi-file = /var/www/webpage.com/env/hello.py
virtualenv = /var/www/webpage.com/env
chdir = /var/www/webpage.com/env
touch-reload = /var/www/webpage.com/reload
/var/log/nginx/webpage.com_error.log
2014/01/17 16:28:58 [error] 25073#0: *13 connect() to unix:///var/run/webpage.com.uwsgi.socket failed (111: Connection refused) while connecting to upstream, client: 83.109.132.224, server: webpage.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///var/run/webpage.com.uwsgi.socket:", host: "webpage.com"
hello.py
只是一个简单的 hello world 应用程序。
已经为此苦苦挣扎了几个小时......现在我需要帮助:)
最佳答案
查看此处发布的配置文件,您将 nginx 中的套接字引用为:
uwsgi_pass /var/run/webpage.com.uwsgi.socket;
在 uwsgi 中作为
socket = /tmp/webpage.com.sock
关于python - Nginx 和 uWSGI : Connection refused and 502 Bad Gateway error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21190394/