Install PmWiki

Overview

PmWiki is a simple and lightweight wiki that doesn't require a database. Instead, content for the wiki is stored in simple text files. Its only requirement is PHP, making it very simple to host with OpenBSD's openhttpd. It also does not require the user's browser to support javascript, which helps improve accessibility.

Install

Download a copy of PmWiki. In this guide, we'll grab the latest stable release.

$ ftp https://www.pmwiki.org/pub/pmwiki/pmwiki-latest.tgz
$ tar xvzf pmwiki-latest.tgz
$ doas mv pmwiki-2.2.141/ /var/www/htdocs/wiki.example.com
$ doas chown -R www:daemon /var/www/htdocs/wiki.example.com

Make sure to replace wiki.example.com with your actual domain name. For flexibility, we recommend you run your own nameserver using nsd and create a records for wiki.example.com.

Configure OpenHTTPd

Before you begin, make sure you have PHP installed.

Next, add a new block to /etc/httpd.conf:

server "wiki.example.com" {
	listen on * port 80
	location "/.well-known/acme-challenge/*" {
		root "/acme"
		request strip 2
	}
        location "*.php" {
                fastcgi socket "/run/php-fpm.sock"
		root "/htdocs/wiki.example.com"
        }
	directory {
		index "index.php"
	}
        connection max request body 104857600
}

Lines 7-8 above tell httpd to evaluate any file that ends with .php as a PHP script. Line 9 says that the document root for the web files is /htdocs/wiki.example.com. Keep in mind, however, that httpd automatically chroots to /var/www/, so the actual path will be /var/www/htdocs/wiki.example.com/.

Line 11-13 tell httpd to automatically serve index.php as the default file when a directory is requested by the user. In other words, if a user requests https://wiki.example.com, he will actually receive https://wiki.example.com/index.php.

Line 14 tells httpd that it can receive uploads as large as 100MB. By default, httpd is limited to only 1MB, so this setting is necessary if you want to allow large file uploads for your wiki.

While not required, it helps to put in /var/www/htdocs/wiki.example.com/index.php:

<?php include('pmwiki.php');

Then give it proper permissions:

$ doas chown www:daemon /var/www/htdocs/wiki.example.com/index.php

Finally, restart httpd:

$ doas rcctl restart httpd

Use your browser to view http://wiki.example.com.

To add TLS, you can use either relayd for TLS acceleration (recommended) or openhttpd's TLS?.

Configuring PmWiki

Copy the sample configuration file and then edit it:

$ doas cp /var/www/htdocs/wiki.ircnow.org/docs/sample-config.php /var/www/htdocs/wiki.ircnow.org/local/config.php

Edit /var/www/htdocs/wiki.ircnow.org/local/config.php.

Documentation

Make sure you get familiar with the docs. They are located in:

/var/www/htdocs/wiki.ircnow.org/README.txt
/var/www/htdocs/wiki.ircnow.org/docs/

Mirroring Content

When mirroring content, you want to skip the passwords in these two files:

/var/www/htdocs/wiki.example.com/local/config.php
/var/www/htdocs/wiki.example.com/wiki.d/SiteAdmin.AuthUser

Password Protect Pages

To change the password prompt page, edit Site.AuthForm.

By default, PmWiki allows creation of password hashes using blowfish, so in the command line, you can type:

$ blowfish
TypeYourPasswordThenPressCtrl+d
$2b$09$KcHFdL42rABog//yC9qehuv0wHgu19QqVHOnhW1zutMC/esVfDfwa

You can use these password hashes for https://example.com/index.php?n=SiteAdmin.AuthUser

Clean URLs

The following URL rewrite rules can provide 'clean' URLs:

        location match "/pub/(.*)" {
                request rewrite "/pub/%1"
        }
        location match "/cookbook/(.*)" {
                request rewrite "/cookbook/%1"
        }
        location match "/uploads/(.*)" {
                request rewrite "/uploads/%1"
        }
        location match "/local/(.*)" {
                request rewrite "/local/%1"
        }
        location match "/favicon.(.*)" {
                request rewrite "/favicon.%1"
        }
        location match "/(.*)/(.*)" {
                request rewrite "/index.php?n=%1.%2?$QUERY_STRING"
        }
        location match "/(.*)" {
                request rewrite "/index.php?n=%1?$QUERY_STRING"
        }

Edit /var/www/htdocs/pmwiki/local/config.php:

$EnablePathInfo = 1;
$ScriptUrl = 'https://wiki.example.com';
$PubDirUrl = 'https://wiki.example.com/pub';
$UploadDir = "/var/www/htdocs/wiki.example.com/pmwiki/uploads";
$UploadUrlFmt = "https://wiki.example.com/uploads";