2013-01-19 12 views
7

ich mit WSGI für ein bestimmtes Verzeichnis auf Apache einrichten Python bin versucht, aber ich die folgende Fehlermeldung erhalten:Einrichten Python mit WSGI auf Apache für ein Verzeichnis

mod_wsgi (pid=3857): Target WSGI script '/var/www/test/test.py' does not contain WSGI application 'application'. 

Mein test.py enthält:

print 'Hello, World!' 

Und mein wsgi.conf enthält:

LoadModule wsgi_module modules/mod_wsgi.so 

WSGIPythonHome /usr/local/bin/python2.7 

Alias /test/ /var/www/test/test.py 

<Directory /var/www/test> 
    SetHandler wsgi-script 
    Options ExecCGI 
    Order deny,allow 
     Allow from all 
</Directory> 

Hinzu kommt, dass alle interessanterweise den Web-Browser gibt einen "404 Not Found" -Fehler zurück, aber zum Glück ist die error_log etwas aufschlussreicher.

Was mache ich falsch?

Antwort

13

Sie verwenden WSGI, als wäre es CGI (seltsamerweise ohne Header).

Was Sie tun müssen, um Ihr unmittelbares Problem ist der von http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

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] 

folgenden anpassen Damit Sie application vorhanden sind.

Und aus dem referenzierten Dokument.

Note that mod_wsgi requires that the WSGI application entry point be called 'application'. If you want to call it something else then you would need to configure mod_wsgi explicitly to use the other name. Thus, don't go arbitrarily changing the name of the function. If you do, even if you set up everything else correctly the application will not be found.

+0

Vielen Dank! Macht Sinn. – hanleyhansen

+1

WSGICallableObject AppFunktionsname – arivero