Note: While this may have worked in the past, the combination of John Leach's blog having broken links, the vagueness of some parts of the instructions and the complexity of the fastcgi_params I would recommend using the uWSGI technique instead. http://projects.unbit.it/uwsgi/wiki/Example#MoinMoinonlinenow Worked successfully with MoinMoin 1.9.4 and Nginx 1.0.4. Only the installation of uWSGI was required. More instructions here that assumes a much older Nginx HowTo/NginxWithModWSGI

Configuring NGINX to use MoinMoin via FastCGI

From: http://johnleach.co.uk/words/315/moinmoin-wiki-on-nginx

MoinMoin is in FastCGI mode listening on port 9005. All the fastcgi_param lines up to PATH_INFO are pretty generic and I have them in a separate include.

  if ($uri ~ ^/wiki(.*)?) {
    set $wiki_url $1;
  }
  location /wiki {
      fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
      fastcgi_param  SERVER_SOFTWARE    nginx;
      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    $document_root$fastcgi_script_name;
      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  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;

      fastcgi_param PATH_INFO $wiki_url;
      fastcgi_param SCRIPT_NAME /wiki;
      if (!-f $request_filename) {
        fastcgi_pass 127.0.0.1:9005;
      }
  }

If you don't need moinmoin in subdirectory, a slightly preferable configuration can be done (also, static files):

    location /moin_static {
        alias /path/to/htdocs;
        autoindex on;
    }  # this requires setting `url_prefix_static` to `'/moin_static'` in the wikiconfig
    
    location ~ /moin_static[^/]+/(.*) {
        alias /path/to/htdocs/$1;
    }

    location / {
        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  REQUEST_URI        $request_uri;
        fastcgi_param  PATH_INFO          $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;

        fastcgi_pass unix:/var/run/www/wiki.sock;  # <- or wherever it is; or 127.0.0.1:port.
    }


Above details the NGINX side of things, but FastCGI requires a separate process to be spawned which fastcgi_pass points to.

The moin.fcgi file can be modified by adding a bindAddress parameter when creating WSGIServer e.g.

WSGIServer(application, bindAddress="/tmp/fcgi.sock").run()

Further details on parameters can be found at http://trac.saddi.com/flup/browser/flup/server/fcgi_base.py#L930

After that, turn moin.fcgi to a service/daemon according to the OS you are running on and nginx will communicate with it over the specified socket.

MoinMoin: HelpOnConfiguration/IntegratingWithNGINX (last edited 2012-05-07 22:00:56 by 188-223-212-63)