Seite 1 von 1

Pythonscripte als Fast-CGI unter Apache ?

Verfasst: Sonntag 16. April 2006, 23:26
von snakeseven
Hi,
brauche mal Hilfe zur Konfiguration des Apachen, damit meine Python-CGIs als Fast-CGIs laufen. In der 'default-server.conf' habe ich Folgendes eingetragen:

Code: Alles auswählen

#Fast CGI
ScriptAlias /fcgi-bin /srv/www/fcgi-bin/
<Directory /srv/www/fcgi-bin/>
    Options ExecCGI Includes FollowSymlinks
    AddHandler fastcgi-script .py
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
Welche '.conf' muss ich wie editieren, damit der Apache Fast-CGI beim Start lädt ?
In der http.conf

Code: Alles auswählen

LoadModule fastcgi_module    /usr/lib/apache2/mod_fastcgi.so
eintragen, hat nichts gebracht. Beispiele für PhP und Perl gibt es einige im Netz, aber für Python ??

Gruss, Seven

Verfasst: Sonntag 16. April 2006, 23:52
von mitsuhiko

Code: Alles auswählen

<VirtualHost *>
  ServerName myhost.com
  SetHandler fastcgi-script .fcg
  ScriptAlias / /path/to/my/fastcgi.fcg/
</VirtualHost>
fastcgi.fcg:

Code: Alles auswählen

#!/usr/bin/env python
from flup.server.fcgi import WSGIServer
from myapplication import app
WSGIServer(app).run()
myapplication.py

Code: Alles auswählen

from cgi import escape as e

def app(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    yield '<h1>FastCGI Environ</h1><table>'
    for key, value in sorted(environ.items()):
        yield '<tr><th>%s</th><td>%s</td></tr>' % (e(key), e(value))
    yield '</table>'
Ich hoffe das hilft dir.