2012-04-14 121 views
1

我一直在試圖讓Flask在我的webfaction服務器上工作幾個小時而沒有任何結果。無法在Webfaction上部署簡單的Flask應用程序

我按照說明在http://flask.pocoo.org/snippets/65/

我下的htdocs我index.py文件存儲。

import sys 
yourappname = "/home/<myusername>/webapps/myapp/htdocs" 
if not yourappname in sys.path: 
    sys.path.insert(0, yourappname) 

from yourappname import app as application 

然後,我已經加入這個我的httpd.conf文件:

WSGIPythonPath /home/yourusername/webapps/yourapp/htdocs/ 
#If you do not specify the following directive the app *will* work but you will 
#see index.py in the path of all URLs 
WSGIScriptAlias//home/yourusername/webapps/yourapp/htdocs/index.py 

<Directory /home/yourusername/webapps/yourapp/htdocs/> 
    AddHandler wsgi-script .py 
    RewriteEngine on 
    RewriteBase/
    WSGIScriptReloading On 
</Directory> 

然後我有myapp.py在同一htdocs目錄旁邊index.py:

from flask import Flask 
app = Flask(__name__) 

@app.route('/') 
def hello_world(): 
    return 'Hello World!' 

if __name__ == '__main__': 
    app.run() 

我有我的域名在webfaction指向我的項目。按照說明中的說明,默認的index.py在我之前覆蓋新的index.py。但是,我只能得到服務器500.我很抱歉,但在Linux和管理服務器方面,我是一個完全noob。我甚至無法訪問用戶下的錯誤日誌,因爲它表示我沒有權限。

我認爲它與我在linux服務器上安裝燒瓶有關,我通過簡單的安裝來安裝它,它說它安裝了所有的依賴關係,並沒有給出任何錯誤。

+1

你真的應該重新啓動Apache服務器考慮使用mod_wsgi的守護進程模式,而不是嵌入式解釋器。在您的文檔根目錄中放置任何Python代碼也沒有什麼好的理由。 – ThiefMaster 2012-04-14 20:07:19

+0

謝謝,我會研究mod_wsgi的守護進程模式。我也會將我的python代碼移出文檔根目錄。 – 2012-04-14 20:59:58

回答

1

一對夫婦的建議:

  1. 你不應該有MYAPP無處不在,你有yourappname在index.py?
  2. 另外,我假設你已經在'做適當的替換WSGIPythonPath /首頁/ yourusername/webapps /下yourapp/htdocs目錄
  3. 您是否嘗試過通過發行~/webapps/<app_name>/apache2/bin/restart
相關問題