lighttpd forum lighty > FastCGI and python file

Posted by Guillaume (Guest)
on 14.05.2008 12:58
Hi,

I'd like to use fcgi to run various fcgi executables. After many attempt 
I didn't manage to make them work. As I understand fastCGI 
configuration, it sends the requested file to the desired interpreter. 
Fine for PHP. But how can I do to have my executable file executed 
directly, in a "standard" cgi way ? I've noticed the cgi.assign, but 
nothing similar for fastCGI.

Any hint ?

THanks

Guillaume
Posted by Filip Sobalski (dsh) (Guest)
on 16.05.2008 16:46
You've got a nice tutorial here:

http://cleverdevil.org/computing/24/python-fastcgi-wsgi-and-lighttpd

I modified it a bit so I can execute python scripts almost like php.

I am enclosing a tarball which includes the WSGI server and my 
python-simple-fcgi-script-interface-server based on it with an example. 
It's just a dirty hack, but fine for my purposes. It runs 
http://dsh.ath.cx/page/files.

Lighttpd conf to make it work:

server.modules              = ( [...]
                               "mod_fastcgi",
                                [...] )

index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm", "index.fcgi" 
)

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => 
"/var/run/lighttpd/php-fastcgi.socket",
                                   "bin-path" => "/usr/bin/php-cgi"
                                 )
                               ),
			       ".fcgi" =>
			       ( "localhost" =>
			         (
				  "min-procs" => 1,
				  "socket" => "/tmp/fcgi.sock"
				 )
			       )

                            )


!!! And remeber you must execute psfcgi.py before the server starts. The 
best way is to write an additional init.d|rc.d script or include it in 
your lighttpd script.





Posted by Filip Sobalski (dsh) (Guest)
on 17.05.2008 12:29
sorry the link should be http://dsh.ath.cx/files
Posted by Guillaume (Guest)
on 19.05.2008 13:33
Thanks for these infos. I configured lighttpd like this :
fastcgi.server             = ( "tilecache.fcgi" =>
                               (( "bin-path" => 
"/srv/www/htdocs/fcgi-bin/tilecache.fcgi",
                                "socket" => "/tmp/tilecache.socket",
                                "min-procs" => 1,
                                "max-procs" => 32,
                                "max-load-per-proc" => 4,
                                "idle-timeout" => 2,
                                "bin-environment" => 
("PROJ_LIB=/usr/local/share/proj", "-initial-env 
LD_LIBRARY_PATH=/usr/local/lib", "-appConnTimeout 5", "-idle-timeout 2", 
"-init-start-delay 1", "-minProcesses 1", "-maxClassProcesses 32", 
"-startDelay 5")
                               ))
                            )

It works OK, but sometimes slows down on heavy load. I can't figure out 
how to limit the number of fCGI processes. The parameters above (32 
max-procs) don't seem to be taken in consideration.

Any clue ?

Thanks

Guillaume