I like Twiki and I love Nginx. Can they work together? Yes they can.

First: we need a CGI for Nginx. I used to use spawn-fcgi but is not updated for 4 years. So i tried with Simple CGI support for Nginx.

git clone https://github.com/gnosek/fcgiwrap
autoreconf -i
./configure
make
make install

Maybe you need install:

apt-get install libfcgi-dev

A script for start FCGIWrap

#!/usr/bin/perl

use strict;
use warnings FATAL => qw( all );

use IO::Socket::UNIX;

my $bin_path = '/usr/local/sbin/fcgiwrap';
my $socket_path = $ARGV[0] || '/tmp/cgi.sock';
my $num_children = $ARGV[1] || 1;

close STDIN;

unlink $socket_path;
my $socket = IO::Socket::UNIX->new(
    Local => $socket_path,
    Listen => 100,
);

die "Cannot create socket at $socket_path: $!\n" unless $socket;

for (1 .. $num_children) {
    my $pid = fork;
    die "Cannot fork: $!" unless defined $pid;
    next if $pid;

    exec $bin_path;
    die "Failed to exec $bin_path: $!\n";
}

Now install TWiki. Obtain source from TWike Download Page.

Create LocalLib.cfg and put all path (In my case):

$twikiLibPath = "/var/twiki/lib";
$TWiki::cfg{ScriptUrlPaths}{view} = '';
$TWiki::cfg{ScriptUrlPaths}{edit} = '/edit';

And now nginx configuration:

server {
        listen       81;
        server_name  192.168.1.113;
        
        access_log /var/log/nginx/acces_twiki.log;
        error_log /var/log/nginx/error_twiki.log;

	     root /var/twiki;
        index index.html;
        
        location = /favicon.ico {
          return 204;
          access_log     off;
          log_not_found  off;
        }


        rewrite ^/([A-Z].*)  /bin/view/$1;
        rewrite ^/edit/(.*)  /bin/edit/$1;

        location ~ ^/pub/ { allow all; }

        location ~ ^/bin/configure {
          allow all; #remember put deny all after finish configuration
          fastcgi_pass   unix:/tmp/cgi.sock;
          include        fastcgi_params;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }

        location ~ ^/bin/ {
          allow all;
          fastcgi_pass   unix:/tmp/cgi.sock;
          fastcgi_split_path_info  ^(/bin/[^/]+)(/.*)$;
          include        fastcgi_params;
          fastcgi_param  PATH_INFO        $fastcgi_path_info;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         }

    }

And go to web page!

TWiki Screenshot