Как развернуть django с помощью nginx и uwsgi - PullRequest
1 голос
/ 07 февраля 2020

У меня проблема с развертыванием моего django сервера с помощью uwsgi и nginx.

Команда dev_ralph runserver 0.0.0.0:8000 запускает сервер разработки и работает нормально. Но сейчас моя цель - развернуть производственный сервер django, и, как я уже сказал, у меня есть некоторые проблемы с этим.

Мой проект- root -каталог: /home/ralphadmin/uwsgi/capentory-ralph/ralph

Вот nginx -virtualhost-configuration: /etc/nginx/sites-available/ralph.conf и /etc/nginx/sites-enabled/ralph.conf:

# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    # server unix:///home/ralphadmin/uwgsi/capentory-ralph/ralph/mysite.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      80;
    # the domain name it will serve for
    server_name 10.70.7.1; # 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 /var/media;  # your Django project's media files - amend as required
    }

    location /static {
        root /home/ralphadmin/uwsgi/capentory-ralph/ralph/src/ralph/static/; # your Django project's static files
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/ralphadmin/uwsgi/capentory-ralph/ralph/uwsgi_params; # the uwsgi_params file you ins$
    }
}

Как вы можете видеть, мои * * * * * * * * - файлы * * * * * *

И если я попытаюсь подключиться к серверу, в браузере откроется страница по умолчанию nginx: nginx

Буду очень признателен за некоторые полезные комментарии.

----------- Обновление 1

Я исследовал свои nginx -логи и обнаружил следующее:

2020/02/11 15:18:44 [error] 19097#19097: *1 connect() failed (111: Connection refused) 
while connecting to upstream, client: 10.70.7.254, server: 10.70.7.1, request: "GET / 
HTTP/1.1", upstream: "uwsgi://10.70.7.1:8630", host: "10.70.7.1"

2020/02/11 15:31:55 [error] 19492#19492: *1 connect() failed (111: Connection refused) 
while connecting to upstream, client: 10.70.7.254, server: 10.70.7.1, request: "GET 
/favicon.ico HTTP/1.1", upstream: "uwsgi://10.70.7.1:8630", host: "10.70.7.1", 
referrer: "http://10.70.7.1/"

... uwsgi работает, но все еще , это не работает вообще: (

...