Installing Dokuwiki and PHP in NGINX

5 minute read

I was looking to create a wiki for personal use, and wanted to utilise my Raspberry Pi once more as cheap platform to host things. There’s a good number of open source wiki platforms but after considering a few I narrowed my choices down to MediaWiki, Dokuwiki, WikiJS, and Gollum.

  • MediaWiki - (PHP) is very widely used, and is familiar.
  • Dokuwiki - (PHP) indexes with text files, meaning there is no database to manage.
  • WikiJS - (NODE) fresh looking interface and easy to navigate.
  • Gollum - (Ruby) built on top of git integration (I <3 markdown!)


All of the options above are ultimately suitable, but I wanted something which would be easy to setup and maintain. My wiki would also need to be accessible by some friends as they would likely make use of the wiki also. Some of them have no background in development so Gollum was probably out. Markdown is pretty accessible but the basic interface of Gollum put me off, thinking there would have to be some front-end work there to make it clear.


I was intrigued by the prospect of using NODE as it’s completely new to me. Setup looked fairly straightforward but then I noticed the system requirements are higher than DokuWiki or MediaWiki. While WikiJS reportedly uses as little as 200MB of RAM, it is recommended a minimum of 1GB system RAM. This is right on par with the 3b Pi so I figured it was cutting it close. Another minor issue arose when I was showing my friends WikiJS GUI. Most of them had the reaction “That doesn’t look like a wiki”. Not something I considered before but it was important they be little familiar with the interface. It would save me explaining things later.


Widely used and coveted by wikipedia it’s hard not to consider this. The GUI is arguably dated however globally recognised as a wiki. If it wasn’t for DokuWiki’s database free system I probably would have ended up using this.


My initial concern was about how updated the system was – turns out it’s very frequently updated. In fact, the user base is high and also well recieved. I was sold on this one, now on to installing it.


Official installation page:

Installing NGINX

Having used it before I opted for NGINX over other servers. I find that the performance is really good on the Pi, and the NGINX config system is very intuitive.

$ sudo apt-get update
$ sudo apt-get install nginx

With a fresh Pi this is all you need to start the ball rolling. Navigating to the Pi’s local address returns the default NGINX page. Next thing to do is run through the requirements of DokuWiki.

DokuWiki requirements

The first notable issue is to install PHP. For this I used php5-fpm (FastCGI Process Manager)

$ sudo apt-get install php5-fpm php5-gd

One thing to note is there is a potential security problem with one of the settings. If a script is not found, a similarly named script may be executed. This requirement is also noted in /etc/nginx/sites-available/default.

Navigate to the settings file, and make the following changes (As a personal preference I like vim over nano.)

$ sudo vim /etc/nginx/sites-available/default

Change ;cgi.fix_pathinfo=1 to ;cgi.fix_pathinfo=0 this disables the script feature. There are some discussions about this but I just disabled it for now since its not an important feature for this project.

You will want to restart PHP FPM after you make changes to the config.

$ sudo service php5-fpm restart

At this point we have NGINX installed, and php-fpm configured. Next step is to configure NGINX to support PHP through PHP-FPM. This is actually very easy, and NGINX has everything already commented out in the config file.

The default NGINX config file looks like this. You will notice it mentions PHP on line 55. Uncomment the block so that it looks like this:

# pass the PHP scripts to FastCGI server listening on

location ~ \.php$ {
       include snippets/fastcgi-php.conf;
#       # With php7.0-cgi alone:
#       fastcgi_pass;
#       # With php7.0-fpm:
       fastcgi_pass unix:/run/php/php7.0-fpm.sock;

To test if the new config is working we can try to serve phpinfo(); .

  $ sudo vim /usr/share/nginx/html/test.php

Enter <?php phpinfo(); ?> into this file to serve a page with the current version of PHP.

Nagivating to http://pi_address/test.php should yield the php info page. If this is working we can go ahed and clean up the test file $ sudo rm -rf /usr/share/nginx/html/test.php.

Installing DokuWiki

Next we download and extract the DokuWiki files into a new directory. Navigate to your user’s home directory with $ cd.

# Download the compressed file
$ sudo wget
# Unpack
$ sudo tar xzvf dokuwiki-stable.tgz
# Clean up
$ sudo rm dokuwiki-stable.tgz
# Move the unpackaged directory to NGINX
$ sudo mv doku* /usr/share/nginx/html/wiki

Next, we set ownership over the files

$ sudo chown -R www-data /usr/share/nginx/html/wiki/data
$ sudo chown www-data /usr/share/nginx/html/wiki/lib/plugins/
$ sudo chown www-data /usr/share/nginx/html/wiki/conf

All the supporting technology is installed and configured at this point so we can check the address again for the installation process with DokuWiki’s system. Visit http://pi_address/wiki/install.php

Following the visual steps at this point should be easy enough. Just remember to clean up the install page after you are done, and follow the security guidelines at this point suggested by the DokuWiki documentation.