In an effort to obtain a faster and lightweight solution, I decided to use Lighttpd (AKA Lighty) with FastCGI to power MapServer. Snooping around the MapServer site yielded no clues on how to configure Lighty. It turns out to be fairly simple.

Here is the Lighttpd configuration:

fastcgi.server = ( "/maps" => 
                    ( "localhost" =>
                        ( 
                          "socket" => "/tmp/mapserver-fastcgi.socket",
                          "check-local" => "disable",
                          "bin-path" => "/usr/lib/cgi-bin/mapserv",
                          "min-procs" => 1,
                          "max-procs" => 6,
                          "max-load-per-proc" => 4,
                          "idle-timeout" => 20 
                        )
                    ) 
                 )

This tells Lighty that any request containing /maps is really a MapServer FastCGI request. Of course your MapServer binary must be compiled with FastCGI support. You can easily check this by finding the path to your binary (mapserv) and using something similar to:

bucklewheat:~# /usr/lib/cgi-bin/mapserv -v
MapServer version 4.10.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG 
SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WFS_SERVER
SUPPORTS=WCS_SERVER SUPPORTS=FASTCGI SUPPORTS=GEOS INPUT=EPPL7 INPUT=POSTGIS
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE    

If you see SUPPORTS=FASTCGI in the output, you are good to go. If not you'll either have to find a packaged FastCGI version for your platform or compile MapServer.

When you start Lighty, it will create 6 mapserv processes. For information on the fastcgi.server configuration see the mod_fastcgi options.

The check-local option is of special interest. By setting this option to "disable", Lighty won't check to see if /maps actually exists when a request is received. This is the desired behavior for MapServer, since we want to pass the URL parameters off to the mapserv binary. The /maps portion of the URL provides a way to "map" the request to MapServer.

An example of a valid URL under this configuration is:

 http://your_map_host.com/maps?map=/opt/maps/atlas.map&mode;=map&layers;=Topography   

If you need to integrate Lighty into an Apache site, you can use Apache's mod_proxy to route requests for maps to Lighty/Mapserver.

I haven't done any testing to compare performance, however I have noticed that this configuration is a bit more stable than the previous Apache/FastCGI/Mapserver setup. As always, your mileage may vary...