(Last Updated On: July 11, 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.

First, configure your server with public ip address or private if you intend to use it on Private LAN.

ip ad
nmcli con mod eth0 ipv4.addresses 192.168.1.x/24 ipv4.method manual connection.autoconnect yes
nmcli con mod eth0 ipv4.gateway
nmcli con mod eth0 ipv4.dns +ipv4.dns
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 groupinstall "Development Tools"
$ sudo yum -y install  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 Webtatic 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 webtatic repositories to the system:

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum clean all
sudo yum makecache fast

Step 3: Install php 7 and nginx

Install php 7.1 by running the following commands:

$ sudo yum install -y nginx mod_php71w php71w-cli php71w-common \
php71w-gd php71w-mbstring ph p71w-mcrypt php71w-mysqlnd \
php71w-xml  php71w-ldap php71w-fpm

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

$ php -v
PHP Warning: Module 'ldap' already loaded in Unknown on line 0
PHP 7.1.5 (cli) (built: May 12 2017 21:54:58) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 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:

$ sudo certbot-auto certonly -d wiki.mydomain.com www.wiki.mydomain.com

Also 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 suite 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:


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