Howto CGI

lighttpd 2.0 doesn't support running cgi scripts/binaries directly (it is a "non-forking" webserver); so you need a FastCGI wrapper around your CGI applications (sometimes you just don't want or can't convert them to real FastCGI applicatons).
One wrapper for this is

Lighttpd config

Just forward cgi requests to your FastCGI wrapper:

setup {
    module.load ( "mod_fastcgi" );

alias ("/cgi-bin/" => "/usr/lib/cgi-bin");

if req.path =^ "/cgi-bin" {
    index ( "index.cgi", "", "index.html" );
    if phys.path =~ "\.(cgi|pl)$" {
        if phys.is_file {
            fastcgi "unix:/var/run/lighttpd/sockets/www-cgi.sock";

Spawn the FastCGI CGI wrapper

Simple ./run script to spawn rails applications with spawn-fcgi and runit/daemontools:


exec 2>&1

exec /usr/bin/spawn-fcgi -n -s /var/run/lighttpd/sockets/www-cgi.sock -u nobody -U www-data -- /usr/bin/fcgi-cgi

Updated by simmel almost 8 years ago · 3 revisions