nginx 连接到套接字失败,django 和 uwsgi 没有文件或目录

nginx 连接到套接字失败,django 和 uwsgi 没有文件或目录

我正在尝试使用本教程使用 nginx 和 uwsgi 部署 django web 应用程序:数字海洋

我一步一步按照教程进行操作,这些是我的配置文件:

/etc/uwsgi/sites/picknbox.ini:

[uwsgi]

project = picknbox    # Virtual environment name in home directory
base = /home/picknbox    # Home directory path

chdir = /home/picknbox/picknbox/picknbox     # Virtual Env Directory
home = /home/picknbox/picknbox       #Django Project Directory with manage.py$
module = picknbox.wsgi:application     # project name

master = true
processes = 5

socket = /home/picknbox/picknbox/picknbox/picknbox.sock
chmod-socket = 664
vacuum = true

/etc/init/uwsgi.conf:

description "uWSGI application server in Emperor mode"

start on runlevel [2345]
stop on runlevel [!2345]

setuid picknbox
setgid www-data

exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites

在/etc/nginx/sites-available/picknbox中:

upstream django {
    server unix:/home/picknbox/picknbox/picknbox/picknbox.sock;
}

server {
    listen 80;
    server_name picknbox.com; # IP Address or FQDN

    location /static/ {
        root /home/picknbox/picknbox/picknbox;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/home/picknbox/picknbox/picknbox/picknbox.sock;
    }
}

但是我收到 502 网关错误。Nginx 日志:

2016/06/12 11:46:58 [crit] 10313#0: *15 connect() to unix:/home/picknbox/pickbox/picknbox/picknbox.sock failed (2: No such file or directory) while connecting to upstream, client: 162.220.220.85, server: picknbox.com, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/home/picknbox/picknbox/picknbox/picknbox.sock:", host: "picknbox.com"

我该如何解决这个错误?

答案1

您应该使用ps命令检查应用服务器是否正在运行。如果没有,您需要使用service命令启动它。

相关内容