2014-03-25 127 views
3

我試圖通過uWSGI將燒瓶應用部署到Nginx上,Fedora 20作爲操作系統,而且我遇到了一些問題。燒瓶+ 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 

不確定。其次,當我直接在命令行中運行它:

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

我得到:

*** 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錯誤。我注意到這個stackoverflow後:Flask, nginx, and uwsgi與一個類似的問題,其中up​​voted答案涉及套接字權限不正確。然而,我確實有使用chmod插槽= 666參數,查看/ tmp目錄:

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

所以也沒有看我,好像這是個問題。

編輯:

意識到我忘了,包括Nginx的錯誤消息:

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" 

我不知道什麼是在這種情況下,「沒有這樣的文件或目錄」的意思。我知道.sock文件存在,所以它在努力尋找什麼?

+0

檢查nginx錯誤日誌,uWSGI正確啓動,因此您需要了解爲什麼nginx無法連接到它。當你開始使用「logto」時,日誌會在指定的文件中,所以在我看到的命令行 – roberto

+0

中看不到更多信息是正常的,但這只是解釋了爲什麼當我使用 - 尼尼國旗。它不能解釋爲什麼我得到了502錯誤,因爲日誌與我在上面發佈的命令行選項的輸出信息相同。 – JackGibbs

+0

刪除logto指令並從終端重新運行uwsgi。之後,嘗試從nginx重新連接(確保始終檢查nginx錯誤日誌)。 「unix套接字上沒有這樣的文件或目錄」意味着沒有進程監聽套接字。如果仍然不起作用,請嘗試使用tcp套接字。 – roberto

回答

0

請更改nginx配置中的字符串,從
uwsgi_pass unix:/tmp/sjudson_app_uswgi.sock;

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/