mod_wsgi
を使用して私のフラスコのアプリケーションをApache上で動かすことを私の探求で繰り返し失敗した後、私はhello world exampleを実行しようと決めました。ここで私が持っているものである -こんにちはWorld in mod_wsgi
ディレクトリ構造を
- public_html
- wsgi-scripts
- test_wsgi.wsgi
- test_wsgi
- test_wsgi.wsgi
test_wsgi.wsgiファイル(私は、Apacheのデフォルト~/public_html
へ/var/www
を変更)
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]
のVirtualHostの設定ファイル(と呼ばれる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を使用する簡単な方法を採用しました。これが起動して実行されるまで私はフラスコのアプリを展開することはできません。どうもありがとう!