How to setup and install docuwiki on Ubuntu 18.04

Install Ubuntu 18.04

Update repos, install updates and distro upgrades

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo reboot now

Install php pre-reqs

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

Install wget and nginx

sudo apt-get -y install wget nginx

Install docuwiki as of this update the stable release is 2018-04-22a

wget https://github.com/splitbrain/dokuwiki/archive/release_stable_2018-04-22a.tar.gz
extract the zip using tar

tar xvf release_stable_2018-04-22a.tar.gz
sudo mv dokuwiki-release_stable_2018-04-22a /var/www/html/dokuwiki
add permissions for www-data to docuwiki directory

sudo chown -R www-data:www-data /var/www/html/docuwiki
Copy SSL Certificates to wiki server See SSL

Configure cert and key REMEMBER – nginx launches as root but traverses directories as www-data

sudo mkdir /etc/private
sudo mkdir /etc/private/key
sudo mv privkey.pem /etc/private/key
sudo mv fullchain.pem /etc/private
sudo chown -R root:root
sudo chmod -R 500 /etc/private

Configure nginx

edit nginx conf

sudo nano /etc/nginx/conf.d/dokuwiki.conf
NOTE – change wiki.emzy.me to the name of your server

server {

listen 443 ssl;
server_name wiki.emzy.me;
root /var/www/html/docuwiki/;

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

ssl on;
ssl_certificate /etc/private/fullchain.pem
ssl_certificate_key /etc/private/key/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/ @docuwiki;
}

location @docuwiki {
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;
}
}

server {
listen 80;
server_name wiki.emzy.me;
add_header Strict-Transport-Security max-age=2592000;
return 301 https://$host$request_uri;
}
Restart ubuntu

sudo shutdown -r now

Open web url for wiki and walkthrough install.php https://wiki.emzy.me/install.php

When complete, delete the install.php script on the wiki server

sudo rm /var/www/html/docuwiki/install.php

Author: Nathan Emslander