Z
Z
zkweb2015-08-25 15:15:57
Django
zkweb, 2015-08-25 15:15:57

How to fix a bug with Uwsgi?

Ubuntu 15 server
Nginx 1.8
Uwsgi 2.0
From the console with the command: uwsgi --ini test.ini django starts successfully!!! Test.ini
file listing

[uwsgi]
    http-socket = :8086
    plugins = python
    virtualenv = /home/adminko/virtualenv/test/
    chdir = /home/adminko/projects/test/
    env = DJANGO_SETTINGS_MODULE=test.settings
    module = django.core.wsgi:get_wsgi_application()

I stop test.ini and it is clear the site is unavailable. This is clear.
Now I can't figure out how to run a website using uwsgi+nginx.
/home/adminko/projects/test - here is the django project (manage.py)
in the same directory (I don't know if this is correct):
  1. termofort.ini
  2. uwsgi.sock (I created this file by hand, I didn’t understand exactly about it)

/home/adminko/virtualenv/test - virtual environment
  1. bin
  2. include
  3. lib
  4. local

nginx config file :
server {
    listen   8080;
    server_name   test;
    error_log    /home/adminko/projects/test/logs/nginx.error.log;

    location /static/ {
        alias    /home/adminko/projects/test/files/static/;
    }
    location /media/ {
        alias    /home/adminko/projects/test/files/media/;
    }

    location / {
        include    uwsgi_params;
       uwsgi_pass      unix:/home/adminko/projects/test/uwsgi.sock;
    }
}

As a result, nginx cannot start the django site. Error 502
In nginx logs 2015/08/25
16:03:16 [error] 2434#0: *1 connect() to unix:/home/adminko/projects/test/uwsgi.sock failed (111: Connection refused ) while connecting to upstream, client: 172.20.1.68, server: test, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/home/adminko/projects/test/uwsgi.sock :", host: "172.20.1.222:8080", referrer: " 172.20.1.222:8080 "
How to fix, please tell me?
All manuals have already read what and where.
And another question, I don’t need to run the uwsgi --ini test.ini command again through the console , nginx will do the same (or I don’t think correctly)
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2015-08-27
@Bahusss

With this nginx configuration, your test.ini should look like this:

[uwsgi]
    socket = /home/adminko/projects/test/uwsgi.sock
    plugins = python
    virtualenv = /home/adminko/virtualenv/test/
    chdir = /home/adminko/projects/test/
    env = DJANGO_SETTINGS_MODULE=test.settings
    module = django.core.wsgi:get_wsgi_application()

As for nginx, you think wrong - it will not start uwsgi for you and will give you a 502 code. If the constantly open console from running uwsgi bothers you, start it as a daemon using the daemonize parameter , add to the config:
daemonize = [путь к лог файлу uwsgi]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question