16
在我試圖讓我的燒瓶應用程序在Apache上運行使用mod_wsgi
反覆失敗後,我決定嘗試運行hello world example。以下是我有 -Hello World在mod_wsgi
目錄結構(我改變了apache默認/var/www
到~/public_html
)
- public_html
- wsgi-scripts
- test_wsgi.wsgi
- test_wsgi
- test_wsgi.wsgi
test_wsgi.wsgi文件
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
虛擬主機配置文件(稱爲testwsgi) - 此駐留in /etc/apache2/sites-enabled/
<VirtualHost *:80>
DocumentRoot ~/public_html/test_wsgi
<Directory ~/public_html/test_wsgi>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /wsgi ~/public_html/wsgi-scripts/test_wsgi.wsgi
<Directory ~/public_html/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
當我嘗試在瀏覽器上訪問localhost/wsgi
時,出現404 Not Found錯誤。我究竟做錯了什麼?這是我第一次嘗試在生產服務器上部署應用程序。到現在爲止,我使用了Google App Engine的簡單方法。我無法繼續部署我的燒瓶應用程序,直到它啓動並運行。非常感謝!