2017-11-25 5 views
0

Ich versuche, mein django(1.8) Projekt auf Nginx Server laufen, da es viel schneller ist. Ich bin in der Lage, mit uwsgi --ini Befehle zum Setup-Socket ausführen. Also, was ich will, ist durch Ausführen NGINX allein mein Projekt django laufen lassen, gibt es eine Möglichkeit, das zu tun? Nun wird der von uwsgi erstellte Socket automatisch entfernt, wenn der Befehl uwsgi --ini endet.Serving NGINX mit DJANGO auf Ubuntu

NGINX config and .ini ia as shown below : 

# mysite_nginx.conf 

# the upstream component nginx needs to connect to 
upstream django { 

    server unix:///var/www/html/vir/crum/crumbs.sock; 

} 

    # configuration of the server 
    server { 
     # the port your site will be served on 
     listen  8000; 
     # the domain name it will serve for 
     server_name .localhost.com; 
     charset  utf-8; 


     # max upload size 
     client_max_body_size 75M; # adjust to taste 

     # Django media 
     location /media { 
      alias /var/www/html/alteryx_vir/crum/media; 
     } 

     location /static { 
      alias /var/www/html/vir/crum/static; 

     } 

     # Finally, send all non-media requests to the Django server. 
     location/{ 
      uwsgi_pass django; 

      /var/www/html/vir/crum/uwsgi_params; 
     } 
    } 

    >>> uwsgi.ini file : 

    # mysite_uwsgi.ini file 
    [uwsgi] 

    # Django-related settings 
    # the base directory (full path) 
    chdir   = /var/www/html/vir/crumb/ 
    # Django's wsgi file 
    module   = crum.wsgi 
    # the virtualenv (/alteryx_vir/) 
    home   = /var/www/html/alteryx_vir/ 
    # process-related settings 
    # master 
    master   = true 
    # maximum number of worker processes 
    processes  = 10 
    # the socket (use the full path to be safe 
    socket   = 
    /var/www/html/alteryx_vir/crum/crum.sock 
    #socket   = var/run/uwsgi/crum.sock 


    # ... with appropriate permissions - may be needed 
    chmod-socket = 666 
    # clear environment on exit 
    vacuum   = true 

Vielen Dank im Voraus für Sie helfen.

Antwort

0

Ja Atlast ich könnte alles automatisieren mit UWSGI EMPEROR-Modus. Jetzt können alle Befehle automatisiert werden, alles was Sie tun müssen, ist NGINX Server zu starten.

emperror Mode:

bearbeiten /etc/rc.local und fügen:

/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data --daemonize /var/log/uwsgi-emperor.log 
0

Was Sie fragen, macht keinen Sinn. Der Socket dient zur Kommunikation zwischen nginx und uWSGI. Wenn uWSGI nicht ausgeführt wird, gibt es nichts am anderen Ende des Sockets und nichts, das Ihre App bedient.

Sie benötigen sowohl nginx als auch uWSGI.

+0

ja ich wurde Danke für Ihre Informationen mr verpassen geführt dann. @Daniel so wie kann ich automatisieren. Ich möchte keinen Befehl ausführen, um uwsgi zu starten. Hoffe, du hast meinen Punkt –

+0

Wie jeder Server-Prozess (einschließlich Nginx selbst), verwenden Sie den Prozess-Manager Ihrer Distribution - zB Systemd oder Upstart - oder etwas wie Supervisord. –