Lighttpd / FastCGI / Python Hell :)
Added by thomasd over 14 years ago
Hi,
I'm using Lighttpd 1.4.27 on CentOS 5, with Python 2.4.3; I have installed flup as well.
The test script comes from this site:
> cat test.cgi #!/usr/bin/python def myapp(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) return ['Hello World!\n'] if __name__ == '__main__': from flup.server.fcgi import WSGIServer WSGIServer(myapp).run()
And the relevant part of my lighttpd.conf is the following:
server.modules += ( "mod_rewrite" , "mod_fastcgi" ) $HTTP["host"] == "" { server.document-root = "" server.follow-symlink = "enable" fastcgi.debug = 1 fastcgi.server = ( ".cgi" => ( "python-fcgi" => ( "socket" => "/tmp/hg.socket", "bin-path" => "/usr/bin/python /srv/www/lighttpd/test.cgi", "check-local" => "disable", "min-procs" => 1, "max-procs" => 1, ) ) ) }
The error log shows this on startup:
2010-08-21 15:49:08: (log.c.166) server started 2010-08-21 15:49:08: (mod_fastcgi.c.1367) --- fastcgi spawning local proc: /usr/bin/python /srv/www/lighttpd/test.cgi port: 0 socket /tmp/hg.socket max-procs: 1 2010-08-21 15:49:08: (mod_fastcgi.c.1391) --- fastcgi spawning port: 0 socket /tmp/hg.socket current: 0 / 1
Lighttpd will send me the content of the CGI file, unprocessed by Python.
and if I add '.cgi' to the static-file.exclude-extensions field, I get a 403 error.
Somehow I must be missing something :) but I've cases nearly identical with PHP and they work, but it's with the old config file, on the previous version of Lighttpd (1.4.26) so maybe some defaults are different.
Thanks for the help!