2014-03-25 5 views
3

나는 페도라 20을 OS로 사용하여 Nginx에 uWSGI를 통해 플라스크 응용 프로그램을 배포하려고하는데 몇 가지 문제가 있습니다. Flask + uWSGI + Nginx + Fedora 20 설정 문제

내가 가지고있는 다음과 같은 구성 파일 :

의 nginx - 다음 편집과 기본 설정 :

location/{ try_files $uri @yourapplication; } 
location @yourapplication { 
     include uwsgi_params; 
     uwsgi_pass unix:/tmp/sjudson_app_uswgi.sock; 
} 

uWSGI : 모든

[uwsgi] 
socket = /tmp/%n.sock 
wsgi-file = sjudson_app/sjudson_app.py 
callable = sjudson 
master = true 
chmod-socket = 666 
logto = /home/server/logs/uwsgi.log 

첫째, 내가 실행하려고 :

uwsgi --ini sjudson_app_uwsgi.ini 

방금 ​​얻은 것 :

[uWSGI] getting INI configuration from sjudson_app_uwsgi.ini 

Indefinetely. 둘째, 내가 명령 줄에서 직접 실행하면

*** Starting uWSGI 2.0.3 (32bit) on [Tue Mar 25 17:58:44 2014] *** 
compiled with version: 4.8.2 20131212 (Red Hat 4.8.2-7) on 25 March 2014 16:48:01 
os: Linux-3.13.6-200.fc20.i686+PAE #1 SMP Fri Mar 7 17:17:53 UTC 2014 
nodename: new-host-6 
machine: i686 
clock source: unix 
detected number of CPU cores: 2 
current working directory: /home/server 
detected binary path: /usr/bin/uwsgi 
!!! no internal routing support, rebuild with pcre support !!! 
your processes number limit is 1024 
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 /tmp/sjudson_app_uwsgi.sock fd 3 
Python version: 2.7.5 (default, Feb 19 2014, 13:47:40) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] 
*** Python threads support is disabled. You can enable it with --enable-threads *** 
Python main interpreter initialized at 0x881cc40 
your server socket listen backlog is limited to 100 connections 
your mercy for graceful operations on workers is 60 seconds 
mapped 127952 bytes (124 KB) for 1 cores 
*** Operational MODE: single process *** 
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x881cc40 pid: 1131 (default app) 
*** uWSGI is running in multiple interpreter mode *** 
spawned uWSGI master process (pid: 1131) 
spawned uWSGI worker 1 (pid: 1136, cores: 1) 

을하지만 서버에 연결하려고 할 때 502 오류가 발생합니다 :

uwsgi --socket /tmp/sjudson_app_uwsgi.sock --wsgi-file sjudson_app/sjudson_app.py --callable sjudson --master --chmod-socket=666 

를 내가 얻을. 나는이 stackoverflow 게시물을 보았다. Flask, nginx, and uwsgi 비슷한 문제가있다. upvoted 대답은 소켓 권한이 정확하지 않은 것과 관련이있다. 그러나, 나는 chmod를 소켓 = 666 인수를 가지고 수행 및/tmp를보고 :

srw-rw-rw-. 1 server server 0 Mar 25 17:53 sjudson_app_uwsgi.sock 

는 그래서 그 문제의 것처럼 나에게 보이지 않는다.

편집 :

2014/03/26 07:58:38 [crit] 792#0: *15 connect() to unix:/tmp/sjudson_app_uswgi.sock 
failed (2: No such file or directory) while connecting to upstream, client: 
173.79.242.54, server: localhost, request: "GET/HTTP/1.1", upstream: 
"uwsgi://unix:/tmp/sjudson_app_uswgi.sock:", host: "173.79.242.54" 

나는이 경우 "해당 파일 또는 디렉토리"의미 있는지 확실하지 않다 :

내가 Nginx에 오류 메시지를 포함하는 것을 잊었다 실현. .sock 파일이 있다는 것을 알고 있습니다. 그래서 무엇을 찾으려고 고민하고 있습니까?

+0

nginx 오류 로그를 확인하면 uWSGI가 올바르게 시작되므로 nginx가 연결할 수없는 이유를 알아야합니다. 그리고 "logto"로 시작하면 로그가 지정된 파일에 있으므로 명령 행에 더 이상 표시되지 않는 것이 정상입니다. – roberto

+0

볼 수는 있지만 그 이유는 내가 더 많은 정보를 볼 때 그 이유를 설명하는 것입니다. --ini 플래그. 로그에 위에서 언급 한 명령 줄 옵션의 출력과 동일한 정보가 있으므로 502 오류가 발생하는 이유는 설명하지 않습니다. – JackGibbs

+0

logto 지시문을 제거하고 터미널에서 uwsgi를 다시 실행하십시오. 그 후 nginx (항상 nginx 오류 로그를 확인하십시오)에서 다시 연결을 시도하십시오. 유닉스 소켓에 "그런 파일이나 디렉토리가 없다"는 것은 소켓을 청취하는 프로세스가 없다는 것을 의미합니다. 그래도 작동하지 않으면 tcp 소켓으로 시도하십시오. – roberto

답변

0

문자열을 nginx 구성으로 변경하십시오.
uwsgi_pass unix : /tmp/sjudson_app_uswgi.sock;
to
uwsgi_pass unix : ///tmp/sjudson_app_uswgi.sock;

1

거의 동일한 설정과 동일한 오류 메시지가 나타납니다.

  • 변화 소켓 문을 내 uwsgi.ini 파일에 :

    socket = 127.0.0.1:8081 
    
  • (서버 문 밖에서) 내 nginx.conf 파일에 다음을 추가 : 그것을 해결하기 위해 내가해야 할 일을했을

    upstream uwsgi { server 127.0.0.1:8081; } 
    
  • nginx.conf 파일의 위치 설명을

    로 변경하십시오.
    location/{ try_files $uri @uwsgi; } 
    location @uwsgi { 
        include uwsgi_params; 
        uwsgi_pass uwsgi; 
    } 
    

이 다음 활성화의 nginx와 uwsgi은 의사 소통. 이 지침은 http://blog.djcentric.com/setting-up-uswgi-nginx-what-you-need-to-know/에서 가져 왔습니다.