(Last Updated On: October 2, 2018)

This guide will take you through steps to Install Dokuwiki behind nginx and letsencrypt on CentOS 7 Linux. But before we can do any installation, I’ll assume you have a newly provisioned CentOS 7 Linux server that you need to do some prereqs prior to setting up Dokuwiki.

Let’s get started.

Set server hostname

sudo hostnamectl set-hostname wiki.mydomain.com

Step 1: Update system and install Development tools

It is recommended to ensure all system packages are updated:

sudo yum -y update
sudo yum -y install git vim bash-completion curl wget unzip tar

Reboot your server for new changes like kernel to take effect:

sudo reboot

Step 2: Add epel and Remi repository for php 7.x

Once the server is up after a reboot, proceed to install all required php modules including php fpm used by Nginx. But first, you’ll need to add epel and remi repositories to the system:

sudo yum install epel-release yum-utils
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum makecache fast
sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php72

Step 3: Install php 7 and nginx

Install php 7 by running the following commands:

sudo yum -y install php-cli php-fpm php-mysql php-zip php-ldap php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath

This should provide all the modules required by DokuWiki. Check your php version:

# php -v
PHP 7.2.10 (cli) (built: Sep 11 2018 11:22:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Step 4: Download Dokuwiki and extract it to your its Document root

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_2018-04-22a

export RELEASE="2018-04-22a"
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 mkdir -p /var/www/html/ 
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 nginx:nginx /var/www/html/dokuwiki/

Step 5: Install Letsencrypt and request for a new certificate

We will request for SSL certificate using certbot-auto. Install it by downloading the binary package and placing it inside /use/local/bin directory:

sudo wget https://dl.eff.org/certbot-auto -P /usr/local/bin
sudo chmod a+x /usr/local/bin/certbot-auto

Once downloaded, open http and https ports on the firewall if you have an active firewall service:

sudo firewall-cmd --add-service {http,https} --permanent
sudo chmod a+x /usr/local/bin/certbot-auto

Then obtain a certificate:

export DOMAIN="wiki.example.com"
export EMAIL="youremailaddress"
certbot-auto certonly --standalone -d $DOMAIN --preferred-challenges http --agree-tos -n -m $EMAIL --keep-until-expiring

Enable nginx service to start on boot:

sudo systemctl enable nginx

Step 6: Configure Nginx

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

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

server {

listen 443 ssl;
 server_name wiki.mydomain.com;
 root /var/www/html/;

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

ssl on;
 ssl_certificate /etc/letsencrypt/live/wiki.mydomain.com/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/wiki.mydomain.com/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-fpm/php-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;
 }
}


server { 
 listen 80;
 server_name wiki.mydomain.com;
 add_header Strict-Transport-Security max-age=2592000;
 rewrite ^ https://wiki.mydomain.com$request_uri? permanent;
}

Step 7: Configure php-fpm and start nginx/php-fpm

Now that we have nginx configured, let’s also configure php-fpm. Open the file:

sudo vim /etc/php-fpm.d/www.conf

Configure below parameters on the file as specified:

user = nginx
group = nginx
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
Start and enable nginx,php-fpm
sudo systemctl start php-fpm nginx
sudo systemctl enable php-fpm

Step 8: Configure DokuWiki on CentOS 7

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

http://mydomain.com/install.php

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.

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:

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

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

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

Select from given Permissions.

Related Articles

How to install and configure DokuWiki on CentOS 7 with Apache, PHP 7.1

How to Install DokuWiki on Ubuntu 18.04 with Nginx and Letsencrypt