installation1Add my vote for this tag create new tag
, view all tags

TWiki on lighttpd using FastCgi

For information on running TWiki on Lighttpd, see TWikiOnLighttpd.

I have been investigating the use of FastCGI rather than plain CGI to run TWiki.

For this initial test, I have set up the default view script to run as a CGI, and a modified view script 'viewd.pl' to run as a FastCGI service.

Execute view.pl as CGI

$HTTP["url"] =~ "^/twiki/bin/" {
    # disable directory listings
    dir-listing.activate = "disable"
    # only allow cgi's in this directory
    cgi.assign = (
      "view.pl"    =>    "/usr/bin/perl"

Run viewd.pl as a FastCGI service

fastcgi.server = ( ".pl" =>
                     ( "localhost" =>
                             "host"      => "",
                             "port"      => 1026,                                       
                             "bin-path"  => "/var/www/localhost/htdocs/twiki/bin/viewd.pl"

The viewd.pl script

#!/usr/bin/perl -w
# Note that, for the moment, the -T flag is not set.
# TWiki Enterprise Collaboration Platform, http://TWiki.org/
# Copyright (C) 1999-2006 Peter Thoeny, peter@thoeny.org
# and TWiki Contributors.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. For
# more details read LICENSE in the root of this distribution.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# As per the GPL, removal of this notice is prohibited.

use CGI::Fast qw(:standard);

    # Set default current working directory (needed for mod_perl)
    if( $ENV{"SCRIPT_FILENAME"} && $ENV{"SCRIPT_FILENAME"} =~ /^(.+)\/[^\/]+$/ ) {
        chdir $1;
    # Set library paths in @INC, at compile time
    unshift @INC, '.';
    require 'setlib.cfg';

while (new CGI::Fast) {

use TWiki::UI::View;
TWiki::UI::run( \&TWiki::UI::View::view );



Using 'ab2' (Apache Bench), the Main WebHome is requested 200 times, with two different concurrency settings.

5 concurrent users


30 concurrent users


-- Contributors: StefanHaflidason


  • An aspect of this setup which I find interesting is the apparent ease with which the view script (or another) could be run on a separate server.

-- Contributors: StefanHaflidason - 09 Aug 2006


Thanks Stefan for contributing this doc. I renamed the topic as suggested. I also added you to the TWikiCommunityGroup so that you can also rename content. Please review what you can/should do in the group topic and use this additional priviledge responsibly.

-- PeterThoeny - 10 Aug 2006

Thank you, Peter. I'll do what I can to help.

-- StefanHaflidason - 11 Aug 2006

Hello! You did execute view.pl as cgi cgi.assign = ( "view.pl" => "/usr/bin/perl" )

Well on apache it was no problem to use view.pl without Extension. How can i do that with lighttpd.

Is there somethin like ScriptAlias ? I was searchin for a long time but didnt find a solution.


-- GeorgSauseng - 12 Oct 2007

Some time ago I started TWikiStandAlone project, and I've just released its first version. There is native support for FastCGI and I wrote some configuration tips to use it with Lighttpd.

Georg, if you use:

cgi.assign = ( "" => "" )

You get similar behavior of Apache's ScriptAlias directive. More info: http://trac.lighttpd.net/trac/wiki/Docs%3AModCGI

-- GilmarSantosJr - 29 Oct 2007

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng lighttpd_cgi_30.png r1 manage 6.5 K 2006-08-09 - 22:29 StefanHaflidason Comparison of CGI vs. FastCGI on Lighttpd with 30 concurrent users.
PNGpng lighttpd_cgi_5.png r1 manage 6.7 K 2006-08-09 - 22:29 StefanHaflidason Comparison of CGI vs. FastCGI on Lighttpd with 5 concurrent users.
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2007-10-29 - GilmarSantosJr
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.