Project

General

Profile

Actions

Howto CGI » History » Revision 2

« Previous | Revision 2/3 (diff) | Next »
stbuehler, 2012-08-11 10:42


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 http://cgit.stbuehler.de/gitosis/fcgi-cgi/.

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.pl", "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:

#!/bin/sh

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 stbuehler over 12 years ago · 2 revisions