Разрешение отказано - развертывание Django на Ubuntu 16.04 с веб-сервером Nginx

Я пытаюсь развернуть сайт django в системе Ubuntu 16.04 с помощью nginx, но у меня возникают проблемы.

ОШИБКИ

Ошибка. Я получаю из файла nginx error.log:

connect() to unix:/home/teddycrepineau/contoursandcolors/contoursandcolors.sock failed (13: Permission denied) while connecting to upstream, client: 64.125.191.37, server: 173.255.210.63, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/home/teddycrepineau/contoursandcolors/contoursandcolors.sock:", host: "173.255.210.63", referrer: "http://173.255.210.63/"

Статус uwgsi:

$ uwsgi status uwsgi[25361]: thunder lock: disabled (you can enable it with --thunder-lock) uwsgi[25361]: uwsgi socket 0 bound to UNIX address /home/teddycrepineau/contoursandcolors/contoursandcolors.sock fd 3 uwsgi[25361]: Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] uwsgi[25361]: !!! Python Home is not a directory: /home/teddycrepineau/Env/contoursandcolors !!! uwsgi[25361]: Set PythonHome to /home/teddycrepineau/Env/contoursandcolors uwsgi[25361]: Fatal Python error: Py_Initialize: Unable to get the locale encoding uwsgi[25361]: ImportError: No module named 'encodings' uwsgi[25361]: Current thread 0x00007f0ec8429700 (most recent call first): uwsgi[25361]: Thu Apr 12 13:31:57 2018 - [emperor] curse the uwsgi instance contoursandcolors.ini (pid: 4955) uwsgi[25361]: Thu Apr 12 13:32:00 2018 - [emperor] removed uwsgi instance contoursandcolors.ini

ОШИБКИ

Использование Python 3 Ubuntu 16.04 Использование Virtualenvwrapper и virtualenv

Настройка виртуального винта

echo "export WORKON_HOME=~/Env" >> ~/.bashrc echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc

/etc/uwsgi/sites/contoursandcolors.ini:

[uwsgi] project = contoursandcolors uid = teddycrepineau base = /home/%(uid) chdir = %(base)/%(project) home = %(base)/Env/%(project) module = %(project).wsgi:application master = true processes = 2 socket = %(base)/%(project)/%(project).sock chmod-socket = 664 vacuum = true

/etc/nginx/sites-available/contoursandcolor:

server { listen 80; server_name 173.255.210.63; location = /favicon.io { access_log off; log_not_found off; } location /static/ { root /home/teddycrepineau/contoursandcolors; } location / { include uwsgi_params; uwsgi_pass unix:/home/teddycrepineau/contoursandcolors/contoursandcolors.sock; } }

/etc/systemd/system/uwsgi.service:

[Unit] Description=uWSGI Emperor service [Service] ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown teddycrepineau:www-data /run/uwsgi' ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites Restart=always KillSignal=SIGQUIT Type=notify NotifyAccess=all [Install] WantedBy=multi-user.target

ЧТО Я ПОЛУЧИЛ

Использование Python 3 Измените местоположение файла сокета из проекта для запуска (получите мне файл не найдена ошибка ) Ubuntu 16.04

Из того, что я прочитал, моя проблема может быть связана с настройкой местоположения virtualenv. Где я должен идти отсюда?

ЧТО Я СДЕЛАЛ

В итоге я использовал gunicorn (вместо uWSGI) , Он отлично работал и был довольно прост в настройке. Вот ссылка на учебник: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 [ ! d25]

0
задан 27 April 2018 в 09:32

0 ответов

Другие вопросы по тегам:

Похожие вопросы: