2014-01-16 125 views
1

我已經創建了燒瓶應用程序,並且到目前爲止,已經使用默認燒瓶服務器來創建/測試它。現在我想將其部署到服務器。我正在使用uwsgi和nginx,但我對兩者都很新穎。我知道有很多的指南以及有關類似的事情的問題,但是我無法找到通過儘可能多的尋找後的解決方案,我可以理解在uwsgi/nginx上運行燒瓶應用程序的問題

以下是從我的uwsgi日誌:

machine: x86_64 
clock source: unix 
detected number of CPU cores: 1 
current working directory: /home/ben/flask/MLS-Flask 
detected binary path: /home/ben/flask/MLS-Flask/mls-flask-ve/bin/uwsgi 
!!! no internal routing support, rebuild with pcre support !!! 
*** WARNING: you are running uWSGI without its master process manager *** 
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 /home/ben/flask/MLS-Flask/mls_uwsgi.sock fd 3 
Python version: 3.3.3 (default, Dec 30 2013, 16:29:41) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] 
Set PythonHome to /home/ben/flask/MLS-Flask/mls-flask-ve 
*** Python threads support is disabled. You can enable it with --enable-threads *** 
Python main interpreter initialized at 0x11755d0 
your server socket listen backlog is limited to 100 connections 
your mercy for graceful operations on workers is 60 seconds 
mapped 72760 bytes (71 KB) for 1 cores 
*** Operational MODE: single process *** 
added /home/ben/flask/MLS-Flask/ to pythonpath. 
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x11755d0 pid: 2926 (default app) 
*** uWSGI is running in multiple interpreter mode *** 
spawned uWSGI worker 1 (and the only) (pid: 2926, cores: 1) 

我假設uwsgi至少運行?我對此很新,所以我不太確定問題所在。

我的nginx的配置是:

server{ 

    listen 8080; 
    charset utf-8; 

    location/{try_files $uri @app; } 
    location @app { 
     include uwsgi_params; 
     uwsgi_pass unix:/home/ben/flask/MLS-Flask/mls_uwsgi.sock; 
    } 
} 

我uwsgi INI是:

[uwsgi] 

uid = nginx 
gid = nginx 

base = /home/ben/flask/MLS-Flask 

home = %(base)/mls-flask-ve 
pythonpath = %(base) 

chdir = /home/ben/flask/MLS-Flask 

module = runp 

#socket file's location 
socket = /home/ben/flask/MLS-Flask/mls_uwsgi.sock 

#permissions for the socket file 
chmod-socket = 666 

#variable that holds a flask application inside the module imported 
callable = app 

#location of log file 
logto = /var/log/uwsgi/%n.log 

和uwsgi INI運行該文件是我的瓶的應用程序:

from app import app 


if __name__ == "__main__": 
    app.run(debug = False, port = 8080) 

我可能在我的uwsgi ini或nginx配置中有一些無關的東西,但我不確定這些是否會成爲問題。任何人都可以看到任何原因,爲什麼這可能不工作?我目前在localhost:8080上得到了一個502錯誤的網關錯誤,所以我猜測它與我的燒瓶uwsgi ini/socket有關。

我很感激任何幫助。

+0

我發佈了這個問題前一陣子,看看你是否能從中得到一些東西。 http://stackoverflow.com/questions/17112805/deploying-a-flask-app-to-hosting-at-godaddy – zee

回答

0

事實證明,我的nginx用戶沒有權限訪問套接字,因爲/和/ home /目錄屬於根組和root用戶。我最終完全訪問了所有者並將其從/目錄中全部路由到套接字(這可能不是最安全的解決方案安全方面的明智之舉,但是在我使所有工作後我可以進一步優化它)。