Невозможно запустить приложение python2 wsgi через ini-файл в Ubuntu 16.04 с uwsgi и nginx - PullRequest
0 голосов
/ 06 марта 2020

Я пытаюсь разместить приложение wsgi python, используя сервер nginx в сочетании с uwsgi. Я успешно установил nginx и uwsgi в Ubuntu16.04. Чем я следовал этому руководству: How-to-serve- python -apps-using-uwsgi-and- nginx -on-centos-7

Я создал каталог с именем opt / myproject inside html.

/var/www/html/opt/myproject

После создания виртуальной среды, файла wsgi и файла ini. Ниже приведен результат команды list "ls".

myproject.ini  myprojectenv  wsgi.py  wsgi.pyc

Ниже приведено то, что содержит мой wsgi-файл:

def application(environ, start_response):
  start_response('200 OK', [('Content-Type', 'text/html')])
  return ["<h1 style='color:blue'>Testing Success!</h1>"]

Также я также изменил свой файл конфигурации nginx: ниже Вот как это выглядит после изменения:

worker_processes 1;

events {

    worker_connections 1024;

}

http {

    sendfile on;

    gzip              on;
    gzip_http_version 1.0;
    gzip_proxied      any;
    gzip_min_length   500;
    gzip_disable      "MSIE [1-6]\.";
    gzip_types        text/plain text/xml text/css
                      text/comma-separated-values
                      text/javascript
                      application/x-javascript
                      application/atom+xml;

    # Configuration containing list of application servers
    upstream uwsgicluster {

        server 127.0.0.1:8080;
        # server 127.0.0.1:8081;
        # ..
        # .

    }

    # Configuration for Nginx
    server {

        # Running port
        listen 80;

        # Settings to by-pass for static files 
        location ^~ /static/  {

            # Example:
            # root /full/path/to/application/static/file/dir;
            root /app/static/;

        }

        # Serve a static file (ex. favico) outside static dir.
        location = /favico.ico  {

            root /app/favico.ico;

        }

        # Proxying connections to application servers
        location / {

            include            uwsgi_params;
            uwsgi_pass         uwsgicluster;

            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;

        }
    }
}

Команда ниже работала нормально, и я смог удаленно получить доступ к результату файла wsgi. uwsgi --socket 0.0.0.0:8080 -w wsgi

Вот что содержит файл myproject.ini:

[uwsgi]
module = wsgi:application
master = true
processes = 5

uid = nginx
socket = /run/uwsgi/myproject.sock
chown-socket = nginx
chmod-socket = 660
vacuum = true

die-on-term = true

Я пытаюсь запустить приложение wsgi через myproject.ini, но не могу сделать это. Ниже приведена команда, которую я использую для запуска моего приложения wsgi. uwsgi --ini myproject.ini

[uWSGI] getting INI configuration from myproject.ini
*** Starting uWSGI 2.0.18 (32bit) on [Fri Mar  6 08:02:37 2020] ***
compiled with version: 5.4.0 20160609 on 05 March 2020 14:11:16
os: Linux-4.4.0-174-generic #204-Ubuntu SMP Wed Jan 29 06:41:58 UTC 2020
nodename: indyguide-nginx
machine: i686
clock source: unix
detected number of CPU cores: 1
current working directory: /var/www/html/opt/myproject
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 15986
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)
bind(): No such file or directory [core/socket.c line 230]
...