R
R
Ramplin2018-03-14 02:12:54
Django
Ramplin, 2018-03-14 02:12:54

django+uWSGI+nginx server setup, no .sock file?

Structure
/data # Shared directory for projects on the server
-------- mysite # Directory for the site mysite
-------- -------- conf # Configuration files for the web server mysite_nginx. conf mysite_uwsgi.ini
-------- -------- project # Project code
-------- -------- --------firstsite # Here settings wsgi
-------- -------- venv # Directory for virtual environment

# mysite_nginx.conf

# the upstream component nginx needs to connect to
# Если будете настраивать несколько django сайтов - измените название upstream
upstream django {
    server unix:///data/mysite/mysite.sock; # for a file socket
}

# configuration of the server
server {
    listen      80;           # порт на котором будет доступен ваш сайт
    server_name .example.com; # доменное имя сайта
    charset     utf-8;

    client_max_body_size 75M; # max upload size  

    # Django media
    location /media  {
        alias /data/mysite/project/media;  
    }

    location /static {
        alias /data/mysite/project/static; 
    }

    location / {
        uwsgi_pass  django;
        include     uwsgi_params; 
        }
    }

# mysite_uwsgi.ini file
[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /data/mysite/project
# Django's wsgi file
module          = project.wsgi
# the virtualenv (full path)
home            = /data/mysite/env/virtualenv

# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket
socket          = /data/mysite/mysite.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 664
# clear environment on exit
vacuum          = true
# account to start process
uid             = www-data
gid             = www-data
# Output messages to log
daemonize=/var/log/uwsgi/mysite.log

in /data/mysite/mysite.sock no later I found this file in /root and deleted it (I thought that it would be created when the server was restarted)
Error 502 Bad Gateway when starting the site
How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
darkrain, 2018-03-14
@darkrain

Did you restart uWSGI?
Check permissions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question