Project

General

Profile

Actions

RequestTracker » History » Revision 2

« Previous | Revision 2/8 (diff) | Next »
stennie, 2007-09-10 01:12
add extension mapping for Search/Chart


= Using Request Tracker with lighttpd (via FastCGI, using Mason) =

[http://bestpractical.com/rt/ Best Practical Solutions' Request Tracker] (RT), an enterprise-grade ticketing system which enables a group of people to intelligently and efficiently manage tasks, issues, and requests submitted by a community of users, can be used with Lighttpd.

Setting up RT3 is somewhat similar to [wiki:MasonRecipe using Mason with Lighttpd and FastCGI], apart from some minor configuration differences.

Setting up RT on Lighttpd requires the following: * Satisfy all Perl dependencies for RT * Mason handles the files ending with '/' or '.html' or '.css' or '.js'. * Mason handles 'mail-gateway', required for the RT mail gateway * Mason handles 'Search/Chart', required for charting search results * Other files statically served by Lighttpd * Required Perl modules load when the FastCGI process starts * Disallow access to .mhtml files

This document assumes you install your Request Tracker in /opt/rt3/

First we need a Mason handler, which is a patched version of the handler that comes with the RT installation. Lighttpd will use this handler via FastCGI. In my setup the handler is called mason_lighttpd_handler.fcgi, the handler does not need to be in any particular location.

{{{
#!perl
#!/usr/bin/perl
  1. BEGIN BPS TAGGED BLOCK {{{
  2. COPYRIGHT:
  3. This software is Copyright (c) 1996-2006 Best Practical Solutions, LLC
  4. <>
  5. (Except where explicitly superseded by other copyright notices)
  6. LICENSE:
  7. This work is made available to you under the terms of Version 2 of
  8. the GNU General Public License. A copy of that license should have
  9. been provided with this software, but in any event can be snarfed
  10. from www.gnu.org.
  11. This work is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. CONTRIBUTION SUBMISSION POLICY:
  19. (The following paragraph is not intended to limit the rights granted
  20. to you to modify and distribute this software under the terms of
  21. the GNU General Public License and is only of importance to you if
  22. you choose to contribute your changes and enhancements to the
  23. community by submitting them to Best Practical Solutions, LLC.)
  24. By intentionally submitting any modifications, corrections or
  25. derivatives to this work, or any other work intended for use with
  26. Request Tracker, to Best Practical Solutions, LLC, you confirm that
  27. you are the copyright holder for those contributions and you grant
  28. Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
  29. royalty-free, perpetual, license to use, copy, create derivative
  30. works based on those contributions, and sublicense and distribute
  31. those contributions and any derivatives thereof.
  32. END BPS TAGGED BLOCK }}}
    package RT::Mason;

use strict;
use vars '$Handler';
use File::Basename;
require ('/opt/rt3/bin/webmux.pl');

  1. Enter CGI::Fast mode, which should also work as a vanilla CGI script.
    require CGI::Fast;

my $h;

RT::Init();

while ( my $cgi = CGI::Fast->new ) { # the whole point of fastcgi requires the env to get reset here.. # So we must squash it again
$ENV{'PATH'} = '/bin:/usr/bin';
$ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'};
$ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'};
$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();
if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
&& ( $Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
$cgi->path_info( $cgi->path_info . "/index.html" );
}
eval { $Handler->handle_cgi_object($cgi); };
if ($) {
$RT::Logger->crit($
);
}
RT::Interface::Web::Handler->CleanupRequest();

}

1;
}}}

Now we set up the host that we'll use for our RT installation, telling Lighttpd to pass all necessary requests to the site through FastCGI.

{{{
#!python
$HTTP["host"] =~ "site1\.example\.com" { # Specify the documentroot
server.document-root = "/opt/rt3/share/html"

  1. Map appropriate files and extensions
    fastcgi.map-extensions = ( ".css" => ".html", ".js" => ".html", "/" => ".html", "mail-gateway" => ".html", "Search/Chart" => ".html")
  1. Set Lighttpd to check for an index.html file for each directory
    index-file.names = ( "index.html" )
  1. Disallow access to .mhtml files
    url.access-deny = ( ".mhtml" )
setenv.add-environment = (
"SCRIPT_NAME" => "/",
)
  1. Set up an alias for the /NoAuth/images location
    url.rewrite-once = (
    "^/(?!NoAuth/images/)(.*)" => "/$1",
    )
  1. Set up FastCGI handler
    fastcgi.server = ( ".html" =>
    ((
    "socket" => "/tmp/rt-fcgi.socket",
    "bin-path" => "/opt/rt3/bin/mason_lighttpd_handler.fcgi",
    "check-local" => "disable",
    "min-procs" => 2,
    "max-procs" => 2
    ))
    )
    }
    }}}

That's it!

The above Lighttpd configuration will start two instances of the Mason handler script, passing requests to them as appropriate.

= Credits =

Justin Hawkins <> for the initial [wiki:MasonRecipe Using Mason with Lighttpd (via FastCGI)] write-up.

Updated by stennie almost 14 years ago · 2 revisions