DokuWiki is a free and open source wiki software written in PHP. DokuWiki is highly versatile and doesn’t require a database since it works on plain text files. It has a syntax similar to the one used by MediaWiki. This guide will cover the steps to Install DokuWiki on Ubuntu 20.04|18.04 with Nginx and Letsencrypt SSL certificate for encryption.

DokuWiki on Ubuntu 20.04|18.04 Prerequisites:

  • Updated system
  • PHP and php-fpm
  • Nginx or Apache web server
  • certbot-auto for requesting a Certbot certificate

Let’s kick off by making sure all software requirements are installed.

Step 1: Update system packages

Make sure your apt index and all software packages are updated.

sudo apt-get update

After rebooting the system, set system hostname and proceed to install php and all required modules:

sudo hostnamectl set-hostname myserverhostname

Step 2: Install php and required modules

We now need to install php and some php modules required by DokuWiki. Run the following commands to get everything installed.

sudo apt-get -y install php php-curl php-apcu php-fpm php-bcmath php-gd php-intl php-pear php-imap php-memcache libapache2-mod-php php-pspell php-recode php-tidy php-xmlrpc php-mbstring php-gettext php-gmp php-json php-xml php-common

By default, php version 7.2 will be installed on Ubuntu 18.04 and 7.4 on Ubuntu 20.04. You can check version installed using the command php -v

$ php -v
PHP 7.2.5-0ubuntu0.18.04.1 (cli) (built: May 9 2018 17:21:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

To get a list of php extensions installed on your system, use php -m command:

php -m

Step 3: Install Nginx and certbot-auto

Let’s install nginx webserver and certbot-auto which we’ll later use to get a certificate for DokuWiki site.

sudo apt-get update
sudo apt-get install wget nginx
wget https://dl.eff.org/certbot-auto
chmod +x certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto

Step 4: Download and Install DokuWiki

Before downloading any version of DokuWiki, check Github releases page for the latest stable release. As of this writing, the latest stable release is release_stable_2020-07-29

export RELEASE="2020-07-29"
wget https://github.com/splitbrain/dokuwiki/archive/release_stable_${RELEASE}.tar.gz

Extract DokuWiki archive using tar

tar xvf release_stable_${RELEASE}.tar.gz
sudo mv dokuwiki-release_stable_${RELEASE} /var/www/html/dokuwiki

Change ownership of /var/www/html/dokuwiki to www-data user and group.

sudo chown -R www-data:www-data /var/www/html/dokuwiki/

Step 5: Request for Letsencrypt SSL Certificate

Stop nginx since certbot-auto will bind to port 80

sudo systemctl stop nginx

Then request for a certificate:

export DOMAIN='yourdomain'
export EMAIL="youremail"
certbot-auto certonly --standalone -d $DOMAIN \
 --preferred-challenges http --agree-tos -n -m $EMAIL \
 --keep-until-expiring

If successful, certbot will give you a successful message:

# certbot-auto certonly --standalone -d $DOMAIN --preferred-challenges http --agree-tos -n -m $EMAIL --keep-until-expiring

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for wiki.computingforgeeks.com
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/wiki.computingforgeeks.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/wiki.computingforgeeks.com/privkey.pem
   Your cert will expire on 2018-09-29. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Step 5: Configure Nginx with SSL

Enable nginx service

sudo systemctl enable nginx

Create Dokuwiki virtualhost file.

sudo vim /etc/nginx/conf.d/dokuwiki.conf

Add the following content, modify to suit your use case. Replace wiki.mydomain.com with your domain name.

# Dokuwiki Nginx configuration
server {

listen 443 ssl;
 server_name mydomain;
 root /var/www/html/dokuwiki/;

 access_log /var/log/nginx/dokuwiki.access.log;
 error_log /var/log/nginx/dokuwiki.error.log;
 
 ssl on;
 ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;
 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/php7.2-fpm.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;
 }
}

# Redirect http to https
server { 
 listen 80;
 server_name mydomain;
 add_header Strict-Transport-Security max-age=2592000;
 rewrite ^ https://mydomain$request_uri? permanent;
}

Replace all existence of mydomain with your wiki domain.

Check nginx syntax:

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If no error, restart nginx and php-fpm

sudo systemctl restart php-fpm nginx

Step 6: Configure DokuWiki on Ubuntu 20.04|18.04

Start DokuWiki configuration by opening the link: https://wiki.mydomain/install.php, you will get installation page like below:

install dokuwiki ubuntu 18.04 01

Provide admin user details, under,Initial ACL policy choose your policy from one of:

  • Open Wiki – Open for everyone
  • Public Wiki – read for all, uploads and edits for registered users
  • Closed Wiki – Access only for registered users

Check whether you want to Allow users to register themselves

When done, click Save. The wiki page should now be ready.

install dokuwiki ubuntu 18.04 02

Click “your new DokuWiki” to get to DokuWiki home page.

Step 7: Adding users to DokuWiki

If you had selected “Closed Wiki | Public” as your ACL policy, you will be given login page for edits. Log in with admin account you created earlier to start adding other users to the system:

install dokuwiki ubuntu 18.04 login

Click “Admin” icon at the top of the page, this will take you to admin page:

dokuwiki add users 01

Click on “User Manager” to get add user page:

dokuwiki add users 02

Add User details and click “Add” button. After adding a user, you can assign ACL on “Access Control List Management” page.

dokuwiki add user acl

Select from given Permissions.

dokuwiki user permissions

In our next Wiki guides, I’ll cover how to install plugins on DokuWiki to extend its functionalities.

Chezmoi – Securely Manage dotfiles across multiple machines

Install wtfutil Personal Information Dashboard for your terminal

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here