uwsgi 错误 - connect() 到 unix:/home/user/www/www.sock 失败

uwsgi 错误 - connect() 到 unix:/home/user/www/www.sock 失败

我很困惑。我哪里做错了?

项目文件位置:

/home/username/www

/etc/uwsgi/sites/mysite.com

[uwsgi]
project = www
base = /home/username

uid = www-data
gid = www-data

chdir = %(base)/%(project)
home = %(base)/.virtualenvs/%(project)
module = %(project).wsgi:application


master = true
processes = 5

socket = %(base)/%(project)/%(project).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]

respawn

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

/etc/nginx/sites-available/mysite.com:

server {

    listen      80; 
    error_log  /var/log/nginx/mysite_error.log  warn;

    server_name www.mysite.com mysite.com;
    charset     utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/username/www;
    }   

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

    location /media  {
        alias /home/username/www/media;
    }   
}

我遇到了 502 Bad Gateway!我该如何修复此问题?

答案1

在您的 uwsgi 配置中指定套接字:

socket = 127.0.0.1:8000

在 nginx 配置中您有:

uwsgi_pass      unix:/home/username/www/www.sock;

因此,您的套接字配置不正确。

您要么必须将两者更改为 TCP 套接字,要么更改为 Unix 套接字。Unix 套接字是首选,因此您应该在uwsgi配置中包含以下内容:

socket = /home/username/www/www.sock;

或者更好的是,将套接字文件放在 中/var/run/uwsgi.sock

答案2

我发现了问题。我安装了uwsgi‍‍ 两次,但pip还是不行apt-get

因此uwsgi指向错误的安装并且无权创建套接字文件。

相关内容