This guide will take you through steps to Install Dokuwiki behind nginx and letsencrypt on Linux. But before we can do any installation, I’ll assume you have a newly provisioned 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

Update system and install Development tools

yum -y update
yum -y groupinstall "Development Tools"
yum -y install  vim bash-completion curl wget unzip tar

Add epel and Webtatic repository for php 7.x

rpm -Uvh
rpm -Uvh
yum clean all
yum makecache fast

Install php 7 and nginx

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

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

Download Dokuwiki and extract it to your its Document root

wget -c
mv dokuwiki-c5525093cf2c4f47e2e5d2439fe13964.tgz dokuwiki.tgz
tar xvf dokuwiki.tgz -C /var/www/html/ --strip-components=1
setenforce 0

Install Letsencrypt and request for new certificate

wget -P /usr/local/bin
chmod a+x /usr/local/bin/certbot-auto
firewall-cmd --add-service {http,https} --permanent
chmod a+x /usr/local/bin/certbot-auto
certbot-auto certonly -d
certbot-auto certonly -d -d
systemctl enable nginx
vim /etc/nginx/conf.d/dokuwiki.conf

Configure Nginx

systemctl enable nginx
vim /etc/nginx/conf.d/dokuwiki.conf

Add the following content, modify to suite you use case. Replace with your domain name.

server {

listen 443 ssl;
 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/;
 ssl_certificate_key /etc/letsencrypt/live/;
 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;
 add_header Strict-Transport-Security max-age=2592000;
 rewrite ^$request_uri? permanent;
Start and enable nginx,php-fpm
sudo systemctl start php-fpm nginx
sudo systemctl enable php-fpm

Up to this point, you have completed steps to Install Dokuwiki behind nginx and letsencrypt on Linux. You should have a working setup. To complete the installation, go to

Related Articles

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