Nginx met PmWiki
Experimental
20160928 Working config of Nginx and PmWiki.
- PmWiki resides in /home/paul/web
- HTTP en HTTPS both works! This requires schema-less definition of
$ScriptUrl
en$PubDirUrl
in PmWiki configuration (see below). - example taken from https://www.nginx.com/resources/wiki/start/topics/recipes/pmwiki/ with a few additions:
- changed mask
jpe?g
tojp?g
- blocks dot-files (like .htaccess which are relevant only to Apache and should not be accessed through webserver)
/etc/nginx/pmwiki.conf
# 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;
}
/etc/nginx/server-common.conf
# Gebruik in server block: include pmwiki.conf
# bron: https://www.nginx.com/resources/wiki/start/topics/recipes/pmwiki/
# 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; }
/etc/nginx/sites-enabled/default
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;
}
/home/paul/web/local/config.php
PmWiki config.php
moet de volgende schemaloze definitie voor ScriptUrl en PubDirUrl bevatten en EnablePathInfo ingeschakeld:
$PubDirUrl = '//mint/pub';
$EnablePathInfo = 1;
of zo je wilt:
$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 pmwiki-latest.zip
to this folder.
- create
farmconfig.php
and add
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:
- 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');
exit('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD><TITLE>403 Forbidden</TITLE></HEAD>
<BODY><H1>403 Forbidden</H1>
<P>You don\'t have permission to access the requested file.
</BODY></HTML>');