V
V
vitaliyharchenko2016-09-08 17:05:17
Django
vitaliyharchenko, 2016-09-08 17:05:17

Where is the error in setting up uwsgi + nginx + django?

Deploying a project to a server.
I work according to the official manual: uwsgi-docs.readthedocs.io/en/latest/tutorials/Djan...
Uwsgi works, django too. Launched by command:

uwsgi --http :8000 --module quantzone.wsgi

Separately, nginx is also working, I see the "welcome" page when requesting on port 80.
The next step caused difficulties:
uwsgi --socket quantzone.sock --wsgi-file test.py --chmod-socket=666

On startup, a file with .sock permission is created, here are the permissions on it
srw-rw-r-- 1 root root Sep 0 8 16:48 /opt/quantzone/quantzone.sock
The console shows that uwsgi is running, just like django:
*** Starting uWSGI 2.0.13.1 (32bit) on [Thu Sep  8 17:03:09 2016] ***
compiled with version: 4.8.4 on 08 September 2016 15:39:48
os: Linux-3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014
nodename: quant.zone
machine: i686
clock source: unix
detected number of CPU cores: 1
current working directory: /opt/quantzone
detected binary path: /opt/qenv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 518
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address quantzone.sock fd 3
Python version: 3.4.3 (default, Oct 14 2015, 20:37:06)  [GCC 4.8.4]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x8c213c8
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 63988 bytes (62 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x8c213c8 pid: 12776 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 12776, cores: 1)

But when I make a request to quant.zone:8000, uwsgi doesn't respond.
Here is the nginx config file:
# the upstream component nginx needs to connect to
upstream django {
    server unix:///opt/quantzone/quantzone.sock; # for a file socket
    # server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8000;
    # the domain name it will serve for
    server_name .quant.zone; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /media  {
        alias /opt/quantzone/media;  # your Django project's media files - amend as required
    }

    location /static {
        alias /opt/quantzone/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
    }
}

What could be wrong? Already 4 hours on the Internet

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kir aka Dober, 2016-09-08
@dobergroup

chmod-socket=666

At a minimum, the rights were not set as you expected. I assume that nginx does not get permission to write to the socket.
You have a working nginx config. I use the chmod -socket = 664 option in the ini file, it works.

I
Ilya, 2016-09-09
@nuBacuk

You can look at my configs.
https://github.com/minigun/uwsgi-nginx-example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question