September 2006 Archives

I had been fighting for a while to get my lighttpd server to serve up Request Tracker via FastCGI, but I was always having minor configuration issues with it. I finally dug up a handy recipe for a Mason (which is what Request Tracker uses) FastCGI script for use with lighttpd. After incorporating the changes necessary to deal with lighttpd's quirks, I managed to get things working as well as I would like. The following is the diff generated from the stock mason_handler.fcgi script that comes with Request Tracker:

--- mason_handler.fcgi.orig     2006-09-30 16:45:18.000000000 -0400
+++ mason_handler.fcgi  2006-09-01 18:05:16.000000000 -0400
@@ -65,6 +65,16 @@
     $ENV{'ENV'}    = '' if defined $ENV{'ENV'};
     $ENV{'IFS'}    = '' if defined $ENV{'IFS'};

+    my $uri = $ENV{REQUEST_URI};
+    if ($uri =~ /\?/) {
+      $uri =~ /^(.*?)\?(.*)/;
+      $ENV{PATH_INFO} = $1;
+      $ENV{QUERY_STRING} = $2;
+    } else {
+      $ENV{PATH_INFO} = $uri;
+      $ENV{QUERY_STRING} = "";
+    }
+
     Module::Refresh->refresh if $RT::DevelMode;
     RT::ConnectToDatabase();

And the portion of my lighttpd configuration file handling Request Tracker:

  server.document-root = "/usr/local/share/html"
  fastcgi.map-extensions        = ( ".css" => ".html", ".js" => ".html", "/" => ".html" )
  index-file.names              = ( "index.html" )
  url.access-deny               = ( ".mhtml" )
  fastcgi.server                = ( ".html" =>
                                        ((
                                                "socket"        => "/tmp/rt-fcgi.socket",
                                                "bin-path"      => "/usr/local/bin/mason_handler.fcgi",
                                                "check-local"   => "disable",
                                                "min-procs"     => 2,
                                                "max-procs"     => 2
                                        ))
                                )