If you like to document your documents using Markdown-like format, you should try out DokuWiki. DokuWiki syntax is similar to Markdown. It has plugins to extend it and requires no database. Let’s jump in and explore how you can set up DokuWiki on an Ubuntu 22.04 LTS server.
If you are going to use a domain, point it to the server’s IP so that an SSL certificate can be retrieved from Let’s Encrypt.
1- Server preparation
Update the server and enable firewall and open only specific ports.
apt update && apt upgrade
ufw default allow outgoing
ufw default deny incoming
ufw allow 22
ufw allow 80
ufw allow 443
ufw enable
ufw status
We will now install PHP and Apache.
apt install apache2 libapache2-mod-php php php-gmp php-bcmath php-gd php-curl php-mbstring php-intl php-xml php-fpm vim
After installation is completed, enable PHP-FPM:
a2enconf php8.1-fpm
a2dismod php8.1
a2dismod mpm_prefork
a2enmod mpm_event
Enable some Apache modules:
a2enmod ssl rewrite headers deflate cache http2
Enable Apache and PHP-FPM at boot:
systemctl enable apache2
systemctl enable php8.1-fpm
systemctl restart apache2
2- Download DokuWiki
We are now ready to download and install DokuWiki.
cd /var/www
wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
Extract the files from the archive and move them to the HTML directory.
tar xvf dokuwiki-stable.tgz
rm -r /var/www/html/*
shopt -s dotglob
mv dokuwiki-*/* html/
Change the ownership:
chown -R www-data:www-data /var/www/html
3- Apache virtual host
For our setup, we will create a virtual host file.
cd /etc/apache2/sites-available/
vim dokuwiki.conf
Enter the following it (change where necessary).
<VirtualHost *:80>
ServerName DOMAIN.COM
DocumentRoot /var/www/html
<Directory "/var/www/html">
AllowOverride All
Options -Indexes +FollowSymLinks
</Directory>
ErrorLog /var/log/apache2/dokuwiki_error.log
</VirtualHost>
Activate this virtual host file and restart Apache.
a2dissite 000-default.conf
a2ensite dokuwiki.conf
apachectl -t
systemctl restart apache2
4- SSL certificate
If you are using an IP, skip this step. In the case of a domain, run the following commands to get a free SSL certificate from Let’s Encrypt.
apt install certbot
certbot certonly --webroot -w /var/www/html -d DOAMIN.COM
Note down the certificate paths.
5- Update virtual host
Once you have the SSL certificates, it’s time to create a 443 block section in the virtual host file (/etc/apache2/sites-available/dokuwiki.conf).
<VirtualHost *:443>
ServerName DOMAIN.COM
DocumentRoot /var/www/html
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
Protocols h2 http/1.1
<Directory "/var/www/html">
AllowOverride All
Options -Indexes +FollowSymLinks
</Directory>
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|ttf|woff)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
ErrorLog /var/log/apache2/dokuwiki_error.log
SSLEngine on
SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN.COM/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/DOMAIN.COM/fullchain.pem
</VirtualHost>
Save and restart Apache:
apachectl -t
systemctl restart apache2
To automatically redirect from HTTP to HTTPS, add the following to the port 80 block. Don’t forget to restart Apache.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
6- Install DokuWiki
We are done with the setup and configuration parts of the server. We can now proceed to install DokuWiki. Type the URL into the browser and add install.php to it.
URL: https://DOMAIN.COM/install.php
You will see the following screen. Enter your desired wiki name, admin ID, and the rest of the information.
Installation is now complete. You should be able to create your wiki pages and documentation.