2016-08-04 9 views
0

私はAmazon EC2マイクロインスタンスを実行していて、Flaskを使用してPythonアプリケーションを実行したいと考えています。ここでApacheサーバでフラスコのpythonアプリケーションを実行

は、私は単純なファイルのアップロード(それはlocalhost:5000上で正常に動作します)やっている私のapp.pyファイルです。ここで

from flask import Flask 
app = Flask(__name__) 

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

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

をapacheのに接続するadapter.wsgiという名前の私のファイルです。

import sys 
sys.path.insert(0, '/var/www/html/lumos') 

from app import app as application 

最後に、私のhttpd.confファイルで、私は以下を行った:

<VirtualHost *> 
ServerName http://lumos.website.me 
DocumentRoot /var/www/html/lumos 

WSGIDaemonProcess lumos threads=5 
WSGIScriptAlias//var/www/html/lumos/adapter.wsgi 
     <Directory "/var/www/html/lumos"> 
       WSGIProcessGroup lumos 
       WSGIApplicationGroup %{GLOBAL} 
       Order deny,allow 
       Allow from all 
     </Directory> 
</VirtualHost> 
0123私は、Apacheサーバを再起動し、 http://lumos.website.me/に行くとき

はその後、私が得るすべては503です:

Service Temporarily Unavailable 

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. 

Apache/2.2.31 (Amazon) Server at lumos.website.me Port 80 

私はフラスコアプリはApacheサーバ上で動作するように得ることができる方法上の任意のアイデア?

注:私のサーバーは動作しています。

更新:

はここので、私は私の答えを見つけ出す助けエラーログを見て、私のエラーログファイル

[Thu Aug 04 01:34:09 2016] [notice] caught SIGTERM, shutting down 
[Thu Aug 04 01:34:09 2016] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) 
[Thu Aug 04 01:34:09 2016] [notice] Digest: generating secret for digest authentication ... 
[Thu Aug 04 01:34:09 2016] [notice] Digest: done 
[Thu Aug 04 01:34:10 2016] [notice] Apache/2.2.31 (Unix) DAV/2 PHP/5.3.29 mod_wsgi/3.2 Python/2.6.9 configured -- resuming normal operations 
[Thu Aug 04 01:34:14 2016] [error] [client 72.219.147.5] (13)Permission denied: mod_wsgi (pid=30315): Unable to connect to WSGI daemon process 'lumos' on '/etc/httpd/logs/wsgi.30311.0.1.sock' after multiple attempts. 
[Thu Aug 04 01:34:14 2016] [error] [client 72.219.147.5] (13)Permission denied: mod_wsgi (pid=30316): Unable to connect to WSGI daemon process 'lumos' on '/etc/httpd/logs/wsgi.30311.0.1.sock' after multiple attempts., referer: http://lumos.website.me/ 
[Thu Aug 04 01:34:15 2016] [error] [client 72.219.147.5] (13)Permission denied: mod_wsgi (pid=30317): Unable to connect to WSGI daemon process 'lumos' on '/etc/httpd/logs/wsgi.30311.0.1.sock' after multiple attempts. 
+0

サーバーは稼動していますか? – error2007s

+0

ははい、私は私の質問 –

+0

「<のIfModule mod_limitipconn.c> MaxConnPerVhost 100 」下記のおhttpdのファイルにこれを追加し、その後にApacheを再起動し、それが動作するかどうかを確認して、それを更新しましたか? – error2007s

答えて

0

大丈夫です。

私のエラーがあったため:

(13)Permission denied: mod_wsgi (pid=30315): Unable to connect to WSGI daemon process 'lumos' on '/etc/httpd/logs/wsgi.30311.0.1.sock' after multiple attempts. 

私は私のhttpd.confファイルでこのWSGISocketPrefix /var/run/wsgiを追加し、Apacheを再起動します。将来的には私と同じ問題を抱えていることが他の人のために

は、ここに私のエラーの詳細な説明です:

https://code.google.com/archive/p/modwsgi/wikis/ConfigurationIssues.wiki#Location_Of_UNIX_Sockets

1

Please make sure in advance that any app.run() calls you might have in your application file are inside an if name == 'main': block or moved to a separate file. Just make sure it’s not called because this will always start a local WSGI server which we do not want if we deploy that application to mod_wsgi.

上記http://flask.pocoo.orgからの抽出物があり、起こるようですあなたと。

関連する問題