1

I am confused. Where I make mistake?

Project files location:

/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;
    }   
}

I got 502 Bad Gateway! How I can fix this problem?

Chalist
  • 145
  • 2
  • 10

2 Answers2

1

In your uwsgi configuration you specify the socket:

socket = 127.0.0.1:8000

While in nginx configuration you have:

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

So, you don't have the correct socket configuration.

You either have to change both to the TCP socket or to the Unix socket. Unix socket is preferred, so you should have this in your uwsgi configuration:

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

Or even better, have the socket file in /var/run/uwsgi.sock.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
1

I found problem. I install ‍uwsgi‍ twice, by pip and by apt-get too.

So uwsgi points to wrong installation and that has not access to create socket file.

Chalist
  • 145
  • 2
  • 10