@vitaliyharchenko

Где ошибка в настройке uwsgi + nginx + django?

Занимаюсь деплоем проекта на сервер.

Работаю по официальному мануалу: uwsgi-docs.readthedocs.io/en/latest/tutorials/Djan...

Uwsgi работает, django тоже. Запускается командой:
uwsgi --http :8000 --module quantzone.wsgi


Отдельно nginx также исправен, вижу страничку "welcome" при запросе по порту 80.

Следующий шаг вызвал затруднения:

uwsgi --socket quantzone.sock --wsgi-file test.py --chmod-socket=666


При запуске файл с разрешением .sock создается, вот права на него
srw-rw-r-- 1 root root 0 сент. 8 16:48 /opt/quantzone/quantzone.sock

В консоли отображается, что uwsgi запущен, как и 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)


Но когда я обращаюсь с запросом по адресу quant.zone:8000, uwsgi не реагирует.

Вот файл конфигурации nginx:
# 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
    }
}


В чем может быть ошибка? Уже 4 часа в интернете
  • Вопрос задан
  • 2908 просмотров
Пригласить эксперта
Ответы на вопрос 2
dobergroup
@dobergroup
Что-то знаю про РЭР и РЭБ
chmod-socket=666


srw-rw-r-- 1 root root

Как минимум, права задались не так, как Вы ожидали. Предполагаю, что nginx у Вас не получает права на запись в сокет.

Конфиг nginx у Вас вполне рабочий. Опцию chmod-socket = 664 я использую в ini-файле, работает.
Ответ написан
Комментировать
nuBacuk
@nuBacuk
Python/Linux
Можешь мои конфиги глянуть.
https://github.com/minigun/uwsgi-nginx-example
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы