2017-11-25 10 views
0

django(1.8) 프로젝트를 실행하는 것이 훨씬 빠르기 때문에 Nginx 서버에서 실행하려고합니다. 소켓을 설치하기 위해 uwsgi --ini 명령을 사용하여 실행할 수 있습니다. 그래서 내가하고 싶은 일은 NGINX 만 실행하면 내 django 프로젝트를 실행하고 싶습니다. 그렇게 할 방법이 있습니까? uwsgi --ini 명령이 끝나면 잘 만들어진 소켓 uwsgi이 자동으로 제거됩니다. 사전에우분투에서 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

참으로 내가 미스 귀하의 정보 미스터 고맙습니다 다음 안내했다. @ 대니얼 그래서 어떻게 자동화 할 수 있습니다. uwsgi를 시작하기 위해 몇 가지 명령을 실행하고 싶지 않습니다. 희망은 내 포인트 –

+0

모든 서버 프로세스 (nginx 자체 포함)처럼, 당신은 배포자의 프로세스 관리자를 사용 - 예 : systemd 또는 upstart - 또는 supervisord와 같은. –