Fläschchen Hallo Welt mit apache und mod_wsgi zeigt die Dateien im webroot nur

Bin ich versucht, die grundlegenden hello.py aus dem Kolben Website über apache2 mit wsgi. Hier ist, was mein code sieht wie folgt aus:

/var/www/flask_dev/hello.py

from flask import Flask
app = Flask(__name__)

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

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

/var/www/flask_dev/start.wsgi

from hello import app as application

import sys
sys.stdout = sys.stderr

/etc/apache2/sites-available/flask_dev.conf

#Listen 80
ServerName example.com

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    #ServerName example.com

    WSGIDaemonProcess hello user=<myuser> group=<myusersgroup> threads=5 python-path=/var/www/flask_dev

    WSGIScriptAlias / /var/www/flask_dev/start.wsgi
    <Directory /var/www/flask_dev>
           WSGIProcessGroup hello
           WSGIApplicationGroup %{GLOBAL}
           Order deny,allow
           Allow from all
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

/etc/hosts

127.0.0.1    example.com

Nachdem ich laufen sudo a2ensite flask_dev und sudo service apache2 reload (or restart), werde www.example.com gibt nur die Dateien in den webroot. ~~Ich habe das Fehlerprotokoll und wie es aussieht, mod_wsgi und mod_python fangen. Weiß jemand was mir fehlt?~~

Bearbeiten 1
Ich bin jetzt in der Lage, um zu sehen, Meldungen aus dem error-log, und es sieht aus wie ich bin betroffen von https://bugs.launchpad.net/ubuntu/+source/libapache2-mod-python/+bug/1073147 auf Ubuntu 12.04.

Werde ich versuchen neu zu kompilieren später, um die richtige Python-version zu sehen, ob es behebt den Fehler. Für jetzt, während dieser Fehler Auftritt, ich bin immer noch zu sehen, werden die Dateien aufgelistet, wenn ich Besuch example.com.

Fehler.melden Sie

[Mon Jan 13 11:28:06 2014] [notice] caught SIGTERM, shutting down
[Mon Jan 13 11:28:07 2014] [error] python_init: Python version mismatch, expected '2.7.2+', found '2.7.3'.
[Mon Jan 13 11:28:07 2014] [error] python_init: Python executable found '/usr/bin/python'.
[Mon Jan 13 11:28:07 2014] [error] python_init: Python path being used '/usr/lib/python2.7/:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload'.
[Mon Jan 13 11:28:07 2014] [notice] mod_python: Creating 8 session mutexes based on 6 max processes and 25 max threads.
[Mon Jan 13 11:28:07 2014] [notice] mod_python: using mutex_directory /tmp 
[Mon Jan 13 11:28:07 2014] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Mon Jan 13 11:28:07 2014] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Mon Jan 13 11:28:07 2014] [notice] Apache/2.2.22 (Ubuntu) mod_python/3.3.1 Python/2.7.3 mod_wsgi/3.3 configured -- resuming normal operations

Edit 2 Update auf 13.04 gelöst hat die version info. Nun, wenn ich gehen, um example.com ich bekomme einen 403 forbidden-Fehler. Wenn ich Schwanz den Fehler.log sehe ich:

[Mon Jan 13 21:03:41.464815 2014] [:error] [pid 10999:tid 3014634304] [client 127.0.0.1:35067] Attempt to invoke directory as WSGI application: /var/www/flask_dev/

Ich habe versucht, indem AddHandler cgi-script py zu meinem flask_dev.conf, aber das scheint nicht zu funktionieren.

Hat jemand bekommen diese Art von Fehler mit WSGI-Anwendung vor und weiß eine Abhilfe für dieses?

Vielen Dank im Voraus.

Edit 3
Alle source-code funktioniert jetzt

  • Dies kann offensichtlich sein, aber ich war faul und Eingabe von 127.0.0.1/flask_dev und hielt immer ein Verzeichnis-Auflistung, obwohl ich sicher war, mein code war wie die Ihre. Nachdem ich einen Eintrag in der hosts-Datei und ging zu dieser Adresse anstelle der Seite wiedergegeben, wie erwartet.
InformationsquelleAutor David | 2014-01-13
Schreibe einen Kommentar