Maison  >  Questions et réponses  >  le corps du texte

nginx+uwsgi a rencontré des problèmes lors du déploiement de Django

Tout d'abord, l'environnement informatique est Ubuntu 16.10, j'utilise conda pour gérer l'environnement de développement !!!

uwsgi est installé à l'aide de pip

de conda install

fichier ini uwsgi

# backend_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir           = /home/yangtz/developproject/backend

# Django's wsgi file
# wsgi-file = /home/yangtz/developproject/backend/backend/wsgi.py
module          = backend.wsgi

 
# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
socket          = /home/yangtz/developproject/backend/backend/backend.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true

# daemonize = /home/yangtz/developproject/backend/uwsgi.log

backend_nginx.conf

    # the upstream component nginx needs to connect to
    upstream django {
        server unix:/home/yangtz/developproject/backend/backend/backend.sock; # for a file socket
        # server 127.0.0.1:8000; # 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 127.0.0.1; # substitute your machine's IP address or FQDN
        charset     utf-8;
    
        access_log      /home/yangtz/developproject/nginx_access.log;
        error_log       /home/yangtz/developproject/nginx_error.log;
    
        # max upload size
        client_max_body_size 75M;   # adjust to taste
    
        # Django media
        # location /media  {
        #     alias /path/to/your/mysite/media;  # your Django project's media files - amend as required
        # }
    
        location /static {
            alias /home/yangtz/developproject/backend/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
        }
    }

Après avoir démarré sudo uwsgi --ini backend_uwsgi.ini, le résultat est

*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /home/yangtz/developproject/backend
your processes number limit is 63466
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 /home/yangtz/developproject/backend/backend/backend.sock fd 3
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 800448 bytes (781 KB) for 10 cores
*** Operational MODE: preforking ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
no request plugin is loaded, you will not be able to manage requests.
you may need to install the package for your language of choice, or simply load it with --plugin.
!!!!!!!!!!! END OF WARNING !!!!!!!!!!
spawned uWSGI master process (pid: 9293)
spawned uWSGI worker 1 (pid: 9294, cores: 1)
spawned uWSGI worker 2 (pid: 9295, cores: 1)
spawned uWSGI worker 3 (pid: 9296, cores: 1)
spawned uWSGI worker 4 (pid: 9297, cores: 1)
spawned uWSGI worker 5 (pid: 9298, cores: 1)
spawned uWSGI worker 6 (pid: 9299, cores: 1)
spawned uWSGI worker 7 (pid: 9300, cores: 1)
spawned uWSGI worker 8 (pid: 9301, cores: 1)
spawned uWSGI worker 9 (pid: 9302, cores: 1)
spawned uWSGI worker 10 (pid: 9303, cores: 1)

l'interface nginx est

Je l'ai vu !!!!!!!!!!!!! ATTENTION!!!!!!!!!!!!
aucun plugin de requête n'est chargé, vous ne pourrez pas gérer les requêtes
. vous devrez peut-être installer le package pour la langue de votre choix, ou simplement le charger avec --plugin.

J'ai donc ajouté --plugin python3, et le résultat était

Traceback (dernier appel le plus récent) :
Fichier "./backend/wsgi.py", ligne 12, dans <module>

from django.core.wsgi import get_wsgi_application

ImportError : Aucun module nommé 'django'
impossible de charger l'application 0 (mountpoint='') (appelable introuvable ou erreur d'importation)
aucune application chargée en mode dynamique complet
uWSGI s'exécute dans. mode interprète multiple

l'interface nginx devient

nginx se rafraîchit, répond uswgi.

Que faire ? Demandez à Dieu de l'aide. . .

PHP中文网PHP中文网2713 Il y a quelques jours810

répondre à tous(1)je répondrai

  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:09:42

    sudo uwsgi

    Vous avez changé d'environnement. Votre Django n'est pas installé globalement sur le système.

    Si vous utilisez virtualenv, vous pouvez spécifier l'emplacement de virtualenv dans la configuration uwsgi.

    répondre
    0
  • Annulerrépondre