How to install DokuWiki on Ubuntu

How to install DokuWiki on Ubuntu

In this article, we will show you how to install DokuWiki on an Ubuntu 14.04 VPS with PHP-FPM and Nginx. DokuWiki is a simple to use and highly versatile wiki software written in PHP that doesn’t require a database. DokuWiki is easy to install and use, has an amazing variety of extensions and it is open source. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 14.04 VPS.

1. Login to your VPS via SSH

ssh user@vps_IP

2. Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common wget nano

3. Install and configure PHP and required PHP modules

To install the latest stable version of PHP version 7 and all necessary modules, run:

[user]$ sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install php7.0-fpm php7.0-cli php7.0-gd php7.0-xml

Create a new PHP-FPM pool for your user:

[user]$ sudo nano /etc/php/7.0/fpm/pool.d/your_user.conf
[your_user]
user = your_user
group = your_user
listen = /var/run/php-fpm-your_user.sock
listen.owner = your_user
listen.group = your_user
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /

Do not forget to change your_user with your username.

Restart PHP-FPM:

[user]$ sudo service php7.0-fpm restart

4. Download DokuWiki

Create a root directory for your DokuWiki shop using the following command:

[user]$ mkdir -p ~/myDokuWiki.org

Change to the directory:

[user]$ cd ~/myDokuWiki.org

Download the latest release using wget:

[user]$ wget http://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

Extract the zip file in the document root

[user]$ tar xvf dokuwiki-stable.tgz --strip 1

5. Install and configure Nginx

Ubuntu 14.04 comes with Nginx version 1.4, to install the latest stable version of Nginx version 1.8, run:

[user]$ sudo add-apt-repository -y ppa:nginx/stable
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install nginx

Generate a self signed ssl certificate:

[user]$ sudo mkdir -p /etc/nginx/ssl
[user]$ cd /etc/nginx/ssl
[user]$ sudo openssl genrsa -des3 -passout pass:x -out dokuwiki.pass.key 2048
[user]$ sudo openssl rsa -passin pass:x -in dokuwiki.pass.key -out dokuwiki.key
[user]$ sudo rm dokuwiki.pass.key
[user]$ sudo openssl req -new -key dokuwiki.key -out dokuwiki.csr
[user]$ sudo openssl x509 -req -days 365 -in dokuwiki.csr -signkey dokuwiki.key -out dokuwiki.crt

If you don’t want to get warnings associated with self-signed SSL Certificates, you can purchase a trusted SSL certificate.

Next, create a new Nginx server block:

[user]$ sudo nano /etc/nginx/sites-available/myDokuWiki.org
server {

    listen 443 ssl;
    server_name myDokuWiki.org;
    root /home/your_user/myDokuWiki.org;

    access_log  /var/log/nginx/dokuwiki.access.log;
    error_log   /var/log/nginx/dokuwiki.error.log;

    ssl on;
    ssl_certificate /etc/nginx/ssl/dokuwiki.crt;
    ssl_certificate_key /etc/nginx/ssl/dokuwiki.key;
    ssl_session_timeout 5m;
    ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    index index.html index.php doku.php;

    location / {
        try_files $uri $uri/ @dokuwiki;
    }

    location @dokuwiki {
        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
        rewrite ^/(.*) /doku.php?id=$1 last;
    }

    location ~ /(data|conf|bin|inc)/ {
          deny all;
    }

    location ~* \.(css|js|gif|jpe?g|png)$ {
        expires 1M;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm-your_user.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ /\.ht {
        deny all;
    }
}

server {
    listen 443 ssl;
    server_name www.myDokuWiki.org;

    ssl on;
    ssl_certificate /etc/nginx/ssl/dokuwiki.crt;
    ssl_certificate_key /etc/nginx/ssl/dokuwiki.key;
    ssl_session_timeout 5m;
    ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://myDokuWiki.org$request_uri? permanent;
}

server {
    listen 80;
    server_name myDokuWiki.org www.myDokuWiki.org;

    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://myDokuWiki.org$request_uri? permanent;
}

The configuration above will redirect all HTTP traffic to HTTPS and www URLs to non-www.

Do not forget to change your_user with your username.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/myDokuWiki.org /etc/nginx/sites-enabled/myDokuWiki.org

Test the Nginx configuration and restart nginx:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

6. Final Steps

Open https://myDokuWiki.org/install.php in your favorite web browser and you should see the DokuWiki install screen. On this page you’ll need to enter your Wiki name, enable ACL and create a superuser.

Once you are done with the configuration, delete the install.php file:

[user]$ rm ~/myDokuWiki.org/install.php

That’s it. You have successfully installed DokuWiki on your Ubuntu 14.04 VPS. For more information about how to manage your DokuWiki installation, please refer to the official DokuWiki site.


Of course you don’t have to install DokuWiki on Ubuntu, if you use one of our DokuWiki VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to install DokuWiki on Ubuntu,  please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment