2013-01-19 16 views
7

próbuję instalacji Pythona z WSGI dla określonego katalogu na serwerze Apache, ale otrzymuję następujący błąd:Konfigurowanie Python z WSGI na Apache dla katalogu

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

Moja test.py zawiera:

print 'Hello, World!' 

A moja wsgi.conf zawiera:

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> 

na szczycie tego wszystkiego, co ciekawe, przeglądarkę internetową zwraca błąd "404 Not Found", ale na szczęście błąd error_log jest nieco bardziej pouczający.

Co robię źle?

Odpowiedz

13

Używasz WSGI tak, jakby był CGI (dziwnie bez nagłówków).

Co trzeba zrobić, dla najbliższej problem jest dostosowanie następujących od 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] 

tak, że masz application prezent.

I od przywołanego dokumentu.

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

Dziękujemy! Ma sens. – hanleyhansen

+1

Nazwa funkcji aplikacji WSGICallableObject – arivero

Powiązane problemy