Nginx – Installing ikiwiki on nginx – fastcgi/fcgi wrapper

fcginginx

My ultimate goal is to setup ikiwiki, my current goal is to get a fcgi wrapper working for nginx, so I can move on to the next step…

The ikiwiki page points out this page as an example for a fcgi wrapper:

http://technotes.1000lines.net/?p=23

So far I've installed the ikiwiki and libfcgi-perl modules through aptitude:

aptitude install libfcgi-perl
aptitude install ikiwiki

It installed those packages as well as some minimal dependency packages.

So the next step following the guide at technotes, I grabbed http://technotes.1000lines.net/fastcgi-wrapper.pl but I'm not sure where to actually place this file… do I run it as a service?

The script makes a socket file in /var/run/nginx but that directory does not exist.. do I manually create it?

So in addition to the .pl file for the cgi wrapper, I need to also define a separate cgi file for parameters. If my conf looks like this…

    server {
        listen 80;
        server_name notes.domain.org;

        access_log /www/notes/public_html/notes.domain.org/log/access.log;
        error_log /www/notes/public_html/notes.domain.org/log/error.log;

        location / {
                root /www/notes/public_html/notes.domain.org/public/;
                index index.html;
        }

  }

And I don't have a cgi-bin directory, where exactly should I create it within my structure, and regarding that I'd obviously have to update the below before I include it in my conf, but I'm just not exactly sure how this would work out.

# /cgi-bin configuration
location ~ ^/cgi-bin/.*\.cgi$ {
  gzip off;
  fastcgi_pass  unix:/var/run/nginx/perl_cgi-dispatch.sock;  [1]*
  fastcgi_param SCRIPT_FILENAME /www/blah.com$fastcgi_script_name; [2]*
  include fastcgi_params; [3]*
}

Also since the user is www-data and /var/run is root owned, what's the proper way of giving it access?

Any tips appreciated.

Best Answer

you should install fcgiwrap via apitude. worked out of the box.

most of the nginx tutorials suck, because they are either not debian-specific, try to reinvent the wheel or use old software or configuration. so be careful and read a bit more than usual.

fyi, my cgi location block:

location ~ \.cgi {
        root    /usr/lib;
        fastcgi_pass  unix:/var/run/fcgiwrap.socket;
          # Fastcgi parameters, include the standard ones
        include /etc/nginx/fastcgi_params;
        # Adjust non standard parameters (SCRIPT_FILENAME)
        fastcgi_param SCRIPT_FILENAME  /usr/lib$fastcgi_script_name;
        fastcgi_param  AUTH_USER          $remote_user;
        fastcgi_param  REMOTE_USER    $remote_user;

}

the /etc/nginx/fastcgi_params

fastcgi_param   QUERY_STRING        $query_string;
fastcgi_param   REQUEST_METHOD      $request_method;
fastcgi_param   CONTENT_TYPE        $content_type;
fastcgi_param   CONTENT_LENGTH      $content_length;

fastcgi_param   SCRIPT_FILENAME     $request_filename;
fastcgi_param   SCRIPT_NAME     $fastcgi_script_name;
fastcgi_param   REQUEST_URI     $request_uri;
fastcgi_param   DOCUMENT_URI        $document_uri;
fastcgi_param   DOCUMENT_ROOT       $document_root;
fastcgi_param   SERVER_PROTOCOL     $server_protocol;

fastcgi_param   GATEWAY_INTERFACE   CGI/1.1;
fastcgi_param   SERVER_SOFTWARE     nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR     $remote_addr;
fastcgi_param   REMOTE_PORT     $remote_port;
fastcgi_param   SERVER_ADDR     $server_addr;
fastcgi_param   SERVER_PORT     $server_port;
fastcgi_param   SERVER_NAME     $server_name;

the ikiwiki stuff goes in /usr/lib/cgi-bin, you can reach it via http://server/cgi-bin/