Permission Denied - Django Deployment no Ubuntu 16.04 com o servidor da Web Nginx

0

Estou tentando implantar um site django em um sistema Ubuntu 16.04 usando o nginx, mas estou tendo problemas.

ERROS

Erro que recebo do meu arquivo 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/"

Status de 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

SET UP

  • Usando o Python 3
  • Ubuntu 16.04
  • Usando o Virtualenvwrapper e o virtualenv

Virtualenvwrapper configurado

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

O que eu tentei

  • Versão python padrão alterada de 2.7 para 3.5
  • Alterar a localização do arquivo de soquete do projeto para execução (obter um erro de arquivo não encontrado)
  • Eu olhei algumas postagens do StackExchange, mas nenhuma resolveu meu problema até agora

Pelo que li, meu problema pode estar relacionado à configuração de localização virtual. Para onde devo ir daqui?

EDITAR

Acabei usando gunicorn (em vez de uWSGI). Funcionou bem e foi muito fácil de configurar. Aqui está o link para o tutorial: link

    
por Teddy 13.04.2018 / 01:29

0 respostas