2016-08-04 8 views
0

Ich betreibe eine Amazon EC2-Micro-Instanz und ich möchte eine Python-App von ihm mit Flask ausführen.Führen Sie eine Flasche Python-App auf Apache-Server

Hier ist meine app.py Datei, wo ich eine einfache Datei-Upload zu tun (es funktioniert auf localhost:5000 fein):

from flask import Flask 
app = Flask(__name__) 

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

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

Hier ist meine Datei adapter.wsgi benannt ist, es zu Apache verbinden:

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

from app import app as application 

<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:

schließlich in meiner httpd.conf Datei, ich habe folgendes getan Dann

, wenn ich den Apache-Server neu starten, und gehen Sie zu http://lumos.website.me/, alles, was ich bekommen, ist eine 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 

Alle Ideen, wie ich der Kolben-App auf dem Apache-Server zu arbeiten bekommen kann?

Hinweis: Mein Server läuft.

Update:

Hier ist meine Fehlerlogdatei

[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

Läuft Ihr Server? – error2007s

+0

Ja, ich habe es in meiner Frage aktualisiert –

+0

diese zu Ihrem httpd Datei hinzufügen unter „ MaxConnPerVhost 100 “ und dann Apache neu starten und sehen, ob es funktioniert? – error2007s

Antwort

0

Okay, also bei den Fehlerprotokollen der Suche half mir meine Antwort herauszufinden.

Da mein Fehler war:

(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. 

Ich habe dieses WSGISocketPrefix /var/run/wsgi in meiner httpd.conf und Apache neu gestartet.

Für andere Menschen, die das gleiche Problem wie ich in der Zukunft haben kann, ist hier eine ausführlichere Erklärung meiner Fehler:

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.

oben ist Extrakt aus http://flask.pocoo.org, so scheint es passieren mit dir.

Verwandte Themen