Lighttpd + FCGI + Perl, anyone?

Ash Berlin ash_cpan at firemirror.com
Sat Jul 12 00:05:42 BST 2008


On 11 Jul 2008, at 18:56, Gareth Kirwan wrote:

>
>
> On Fri, 2008-07-11 at 18:29 +0100, Iain Barnett wrote:
>> I'm trying to get the above setup to work, but I've found a big fat
>> zero when it comes to useful info on how to do this with perl. The
>> php and ruby crowd have got endless examples! (perhaps mongers are
>> just seen as more resourceful?)
>>
>> If anyone has managed this, I'm most interested in what the
>> fastcgi.server part of the lighttpd.conf looks like, as this is the
>> most fatty part of the "big fat zero".
>>
>>
>> Currently, this won't even let the server start:
>>
>> fastcgi.server    = ( "/fcgi/" =>
>>                       ((
>>                       		"host" => "localhost"
>>                           ,"socket" => "/tmp/lighttpd.socket"
>>                           ,"bin-path" => "/usr/local/bin/perl"
>>                       ))
>>                     )
>
> I've been doing it for quite a while.
> This is an example that expects to find it on one of two sockets, with
> simple round robin.
>
> The fastcgi backend is a catalyst app, running under  
> FCGI::ProcManager.
>
>
> fastcgi.map-extensions  = ( "" => ".dynamic" )
>
> fastcgi.server = ( ".dynamic"
> =>
>  (("socket" =>
> "/etc/lighttpd/sockets/webXG.socket",
>    "check-local" =>
> "disable",
>   ),
>   ("socket" =>
> "/etc/lighttpd/sockets/webXG_update.socket",
>    "check-local" =>
> "disable",
>  )),
> )
>
>

My solution can be found at http://perlitist.com/articles/catalyst-with-lighttpd 
  and I've reproduced the lighttpd conf for you:

$HTTP["host"] =~ "^mysite.com" {
     url.redirect = ( "^/(.*)" => "http://www.mysite.com/$1" )
}

$HTTP["host"] =~ "www.mysite.com" {

     # dir listings are bad in general
     server.dir-listing = "disable"

     accesslog.filename = "/var/log/lighttpd/mysite.com.access.log"

     # Let lighttpd take care of serving that static content
     alias.url = (
       "/favicon.ico" => "/var/www/mysite.com/MySite/root/favicon.ico",
       "/js/"   => "/var/www/mysite.com/MySite/root/js/",
       "/css/"  => "/var/www/mysite.com/MySite/root/css/",
       "/tour/" => "/var/www/mysite.com/MySite/root/tour/",
     )

     # rewrite-once will stop processing after the first match
     url.rewrite-once = (
       "^/((?:js|css|tour)/.*)" => "/$1",
       "^/favicon.ico" => "/favicon.ico",
       "^/(.*)" => "/fcgi/$1"
     )

     fastcgi.server = (
       "/fcgi" => (
         ( "host" => "127.0.0.1", "port" => 3010, "check-local" =>  
"disable"),
         ( "host" => "127.0.0.1", "port" => 3011, "check-local" =>  
"disable")
       )
     )

     $HTTP["url"] =~ "^/" {
       setenv.add-environment = ( "SCRIPT_NAME" => "/" )
     }

}
-ash


More information about the london.pm mailing list