2017-11-25 191 views
0

我试图在Nginx服务器上运行我的django(1.8)项目,因为它速度更快。我可以通过使用uwsgi --ini命令来设置套接字。所以我想要做的就是单独运行NGINX想运行我的django项目,有没有办法做到这一点?那么当uwsgi --ini命令结束时,由uwsgi创建的套接字将自动移除。在Ubuntu上使用DJANGO服务NGINX

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 

在此先感谢您的帮助。

回答

0

是Atlast我可以通过使用UWSGI EMPEROR模式自动执行所有操作。 现在所有的命令都可以自动完成你需要做的就是启动NGINX服务器。

Emperror模式:

编辑/etc/rc.local中并添加:

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

你问的没有意义。套接字用于nginx和uWSGI之间的通信。如果uWSGI没有运行,那么套接字的另一端没有任何内容,并且没有为您的应用程序提供服务。

您需要nginx和uWSGI。

+0

是啊,我是小姐,然后引导thanx您的信息先生。 @丹尼尔,我怎么能自动化。我不想运行一些命令来启动uwsgi。希望你得到了我的观点 –

+0

与任何服务器进程(包括nginx本身)一样,您可以使用发行版的进程管理器 - 例如systemd或upstart - 或supervisord之类的东西。 –

相关问题