1

嗨,我正在尝试让 nginx 和烧瓶在我的本地机器上启动并运行。

我可以用 nginx 很好地服务器静态文件,但我一直遇到 uwsgi 的连接问题。

我的 nginx:

server {
    listen       80;
    server_name  localhost;

location /static {
    alias /path/to/my/static;
    autoindex  on;
}

location /media {
    alias  /media;
    autoindex  on;
}


location / {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/uwsgi.sock;
    uwsgi_param UWSGI_PYHOME /path/to/my/env;
    uwsgi_param UWSGI_CHDIR /path/to/my/app;
    uwsgi_param UWSGI_MODULE application;
    uwsgi_param UWSGI_CALLABLE app;
}

error_page   404              /404.html;

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

}

/etc/uwsgi/apps-available/uwsgi.ini:

[uwsgi]
plugins=python
vhost=true
socket=/tmp/uwsgi.sock

但是如果我尝试 localhost/,我会在 nginx 错误日志中找到:

[error] 1021#0: *16 connect() to unix:/tmp/uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/tmp/uwsgi.sock:", host: "localhost"

我已经尝试更改权限,但我似乎无法解决这个问题。有人有什么建议吗?

任何帮助都感激不尽。

4

1 回答 1

0

一些想法:

  • 你确定uWSGI正在运行吗?
  • 在可用的应用程序中编辑该文件后,您是否重新加载/重新启动它?
  • 从名称 (apps-available) 来看,是否还有另一个名为 apps-enabled 的目录,您需要将符号链接放置到 apps-available 中的文件?
  • 是否存在 uWSGI 正在编写自己的错误消息的日志文件?

您可以使用lsofuWSGI pid(例如lsof -n -p 12345)来查看它打开了哪些文件。您应该在 /tmp 中看到套接字以及 /var/log 中某处的日志文件

于 2013-03-14T00:59:58.000 回答