Prasanna Natarajan

Setting up DocuWiki in an Ubuntu server

I recently decided to setup a personal wiki. I chose docuwiki as it saves the pages as files instead of in database.

Download and setup

Download the customized tgz file from https://download.dokuwiki.org/. I remember selecting all the ‘Popular Plugins’ (especially the CAPTCHA. I want authwall behind my wiki), and also the chosing tamil and English in the languages checkbox. I then scp’d this file to the server.

I mostly followed instructions from https://www.dokuwiki.org/install:ubuntu.

# the obligatory stuff
sudo apt-get update && sudo apt-get upgrade

# install apache2 and dependencies
sudo apt-get install apache2 libapache2-mod-php php-xml

# enable apache2 rewrite module
sudo a2enmod rewrite

# extract and place docuwiki folder
cd /var/www
sudo tar xvf dokuwiki-stable.tgz

sudo chown -R www-data:www-data /var/www/dokuwiki

subdomain setup

I want my site to be accessible in the ‘wiki’ subdomain at “wiki.npras.in”. This means I have to create an ‘A’ type record with name ‘wiki’ and value as my server’s public ip.


Apache2 setup

Follow the steps mentioned in the link above. But I had to fill in some gaps. I disabled the default apache virtualhost conf 000-default.conf (sudo a2dissite 000-default.conf). Instead I created a site conf docuwiki.conf and enabled it. It’s contents were:

<VirtualHost *:80>
    DocumentRoot /var/www/dokuwiki
    ServerName wiki.npras.in
</VirtualHost>

After restarting apache, the docuwiki site is up and running!

The docuwiki app folder has a .htaccess.dist file in its root. Rename it as .htaccess. This, by default is setup to prevent access to important files and dirs. To allow apache to use this, add AllowOverride All in the Directory directive in the main apache2.conf file, like so:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Setting up https using LetsEncrypt

Visiting LetsEncrypt site led me to https://certbot.eff.org/lets-encrypt/ubuntubionic-apache and I’m just following instructions from there.

Got this message after LetsEncrypt finished setup:

Congratulations! You have successfully enabled https://wiki.npras.in

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=wiki.npras.in
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/wiki.npras.in/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/wiki.npras.in/privkey.pem
   Your cert will expire on 2019-07-17. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

(sensitive data changed)

After allowing 443 port in UFW, I was able to access the wiki in https!

The https certificate is valid for 90 days. After that, we can renew it using certbot renew command.