this private cloud

Nginx met PmWiki


20160928 Working config of Nginx and PmWiki.


# Configuratie voor PmWiki
# Gebruik in server block: include pmwiki.conf

index pmwiki.php;

location ~ ^/(cookbook|local|scripts|wiki.d|wikilib.d) {
        deny all;

location / {
    try_files $uri $uri/ @pmwiki;

location @pmwiki {
    rewrite ^/(.*) /pmwiki.php?n=$1;

location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: you should have "cgi.fix_pathinfo = 0;" in php.ini!
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

# cache configuration and sharing for most common files
location ~* \.(?:ico|css|js|gif|jp?g|png|woff)$ {
    # Some basic cache-control for static files to be sent to the browser
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        # IMPORTANT: enable cross-origin resource sharing of the file in farm pub dir for field wikis
        add_header Access-Control-Allow-Origin *;

# deny access to all .dot-files
location ~ /\. {
        deny all;


 Normale configuratie voor servers
# Gebruik in server block: include pmwiki.conf
# bron:

# drop common log errors
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }


server {
    server_name wiki;    
    listen 80 default_server;
    root /home/paul/webs/wiki;

    include pmwiki.conf;
server {
    server_name field1;    
    listen 80;
    root /home/paul/webs/field1;

    include pmwiki.conf;

# HTTPS server

server {
    server_name mint;    
    listen 443 default_server ssl;
    root /home/paul/web;

    ssl on;
    ssl_certificate /etc/nginx/ssl/nginx.cert;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;
    ssl_session_timeout 5m;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
    ssl_prefer_server_ciphers on;

    include pmwiki.conf;


PmWiki config.php moet de volgende schemaloze definitie voor ScriptUrl en PubDirUrl bevatten en EnablePathInfo ingeschakeld:

$ScriptUrl = '//mint';
$PubDirUrl = '//mint/pub';
$EnablePathInfo = 1;

of zo je wilt:

$ScriptUrl = $UrlScheme."://".$_SERVER["HTTP_HOST"];
$PubDirUrl = $UrlScheme."://".$_SERVER["HTTP_HOST"].'/pub';
$EnablePathInfo = 1;

Farm setup

When you have multiple wikis on one web server, and you want to use a single codebase, you should setup a wiki farm.

Create home wiki

Create a home wiki in /home/paul/webs/farm/ by copying the contents of to this folder.

  • create farmconfig.php and add
$FarmPubDirUrl = $UrlScheme.'://farm/pub';

where farm is the FQDN of your server. Also add all your farm-wide customizations, like cookbook recipes that you want to enable on all wiki

Create field wiki

Create a field wiki in /home/paul/webs/field/:

  • create pmwiki.php like this:
<?php include_once('/home/paul/webs/farm/pmwiki.php');
  • mkdir wiki.d
  • mkdir local
  • mkdir cookbook
  • create local/config.php like this:

and add local customizations to suit your needs.

Disable home wiki

It is probably a good idea to disable the home wiki. To do this , edit /home/paul/webs/farm/local/config.php and replace all content with:

# Disable the home wiki for this farm.
header('HTTP/1.0 403 Forbidden');
<HTML><HEAD><TITLE>403 Forbidden</TITLE></HEAD>
<BODY><H1>403 Forbidden</H1>
<P>You don\'t have permission to access the requested file.