Table of Contents

How to setup and configure dokuwiki on AWS Lightsail

Summary: This wiki page shows how I host this wiki using dokuwiki on an AWS lightsail instance. We will setup dokuwiki on AWS Lightsail, and configured it to use git as the backend for the pages and media. We will also setup a certificate using AWS Certificate Manager, and create a CloudFront distribution to serve the dokuwiki pages securely.
Date: 14 July 2025

Overall, the following techniques are used:

Setup a Lightsail LAMP Instance

We need an instance to host dokiwki. We will use an AWS lightsail LAMP instance:

By default, a lightsail instance has a builtin firewall that only allows SSH, HTTP and HTTPS for both IPv4 and IPv6.

Once the instance is available, we can access it from the console to start the configuration.

Further setup the user

We can now login using ssh. For easy access, I've already set the domainname to origin.getshifting.com for the public IP in route53, and setup my ssh config file to use the private key for this host:

Host origin.getshifting.com wiki.getshifting.com wiki
    HostName origin.getshifting.com
    User sjoerd
    IdentityFile C:\Users\sjoer\.ssh\id_ed25519_sjoerd
I'm using origin.getshifting.com as the hostname for now, because this will be the origin for the cloudfront distribution, which will be used to serve the dokuwiki pages. The domain name will be set to wiki.getshifting.com later on.

Now we can login using ssh: ssh origin.getshifting.com

Set the default shell to bash:

sudo chsh -s /bin/bash sjoerd

To enhance our prompt and as we'll be working with git, we will add some git info to the prompy:

wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
mv git-prompt.sh .git-prompt.sh

Now add the following lines to our users's .bashrc file:

# Use the git-prompt script to allow for git information in the prompt
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
. ~/.git-prompt.sh
 
# Uncomment the following line
force_color_prompt=yes
 
# Change the following line
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[34m\]$(__git_ps1 " (%s)")\[\033[00m\]\$ '

Disable MariaDB

We won't need the MariaDB database, as we will be using git as the backend for dokuwiki, so we can disable it. Note that the Bitnami stack uses MariaDB instead of MySQL, so we will check for that first:

sjoerd@wiki:~$ test -d /opt/bitnami/mariadb && echo "MariaDB" || echo "MySQL"
MariaDB
sjoerd@wiki:~$ sudo /opt/bitnami/ctlscript.sh status mariadb
mariadb already running
sjoerd@wiki:~$ sudo /opt/bitnami/ctlscript.sh stop mariadb
Stopped mariadb
sjoerd@wiki:~$ sudo /opt/bitnami/ctlscript.sh status mariadb
mariadb not running

Now that MariaDB is stopped, we can disable it in the monit configuration, so that it won't be started again after a reboot:

sjoerd@wiki:/etc/monit/conf.d$ ls -al
total 24
drwxr-xr-x 2 root root 4096 Apr  3 16:27 .
drwxr-xr-x 3 root root 4096 Apr  3 16:27 ..
-rw-r--r-- 1 root root  323 Apr  3 16:27 apache.conf
-rw-r--r-- 1 root root  324 Apr  3 16:27 mariadb.conf
-rw-r--r-- 1 root root  317 Apr  3 16:27 php-fpm.conf
-rw-r--r-- 1 root root  334 Apr  3 16:27 varnish.conf.disabled
sjoerd@wiki:/etc/monit/conf.d$ sudo mv mariadb.conf mariadb.conf.disabled
sjoerd@wiki:/etc/monit/conf.d$ ls -al
total 24
drwxr-xr-x 2 root root 4096 Jul 10 05:50 .
drwxr-xr-x 3 root root 4096 Apr  3 16:27 ..
-rw-r--r-- 1 root root  323 Apr  3 16:27 apache.conf
-rw-r--r-- 1 root root  324 Apr  3 16:27 mariadb.conf.disabled
-rw-r--r-- 1 root root  317 Apr  3 16:27 php-fpm.conf
-rw-r--r-- 1 root root  334 Apr  3 16:27 varnish.conf.disabled

To make sure that the changes are applied, and test the result we can reboot the server: sudo reboot.

Configure Apache & PHP

For the full background in configuring apache and php for dokuwiki, see the following links:

Apache

DocumentRoot "/opt/bitnami/apache/htdocs"
<Directory "/opt/bitnami/apache/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
Options Indexes FollowSymLinks
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    # AllowOverride None
    AllowOverride All
 
    #
    # Controls who can get stuff from this server.
    #
Require all granted
</Directory>

PHP

Configure dokuwiki

At this point a reboot, sudo reboot is always a good idea, before continuing and configuring dokuwiki:

You should get a message saying that the installation was successful, and you can now login to the wiki, and delete the install.php file sudo rm install.php.

Test Dokuwiki

We can now do a few basic checks to verify everything is working in which we will also install the required dokuwiki plugins:

Git

It is possible to use git as the backend for dokuwiki pages and media, which allows us to get the best of both worlds. This enables me to use both git as well as the dokuwiki frontend to make changes to the content. But the content for the wiki is stored in a larger git repository, so we will use sparse checkout to only checkout the dokuwiki pages and media directories.

Note that git is already installed on the instance (git --version).

Daemon User

Let's start by creating new directories for the pages and media. Note that we first must setup the daemon user, as that's the user the apacher server is running under:

sudo mkdir /home/www
sudo chown daemon:daemon /home/www
# Set the home directory for the daemon user
sudo usermod -d /home/www daemon
# Set the shell for the daemon user to bash
sudo usermod -s /bin/bash daemon
# Check the home directory and shell for the daemon user
sudo cat /etc/passwd | grep daemon
# Output should be:
# daemon:x:1:1:daemon:/home/www:/bin/bash

Now we can logon as the daemon user: sudo su daemon. We will continue the git setup as the daemon user.

Create file structure

Follow these steps to create the file structure for the dokuwiki pages and media:

cd /opt/bitnami/apache/htdocs/
mkdir -p data/gitrepo/dokuwiki/media
mkdir -p data/gitrepo/dokuwiki/pages
# Add the content of the local.php file (see below) to the existing conf/local.php file
sudo vi conf/local.php
# Set the permissions again if required
sudo chown -R daemon:daemon *
sudo chown -R daemon:daemon .[^.]*
$conf['datadir'] = './data/gitrepo/dokuwiki/pages';
$conf['mediadir'] = './data/gitrepo/dokuwiki/media';

Configure git

Configure git on the lightsail instance:

# Configure git
cd /opt/bitnami/apache/htdocs/data/gitrepo
git config --global init.defaultBranch main
git config --global --add safe.directory /opt/bitnami/apache/htdocs/data/gitrepo
git config --global user.email "sjoerd@getshifting.com"
git config --global user.name "Sjoerd Hooft"
git config --global core.editor vi
git config --global http.sslVerify false
# Configure git authentication for push
PAT='see lastpass wiki.getshifting.com'
AUTH=$(echo -n ":$PAT" | openssl base64 | tr -d '\n')
REPO_URL="https://getshiftingcom@dev.azure.com/getshiftingcom/Documentation/_git/knowledge"
git config --global http.$REPO_URL.extraHeader "Authorization: Basic $AUTH"
# Check the git configuration
git config --global --list
# If something is wrong, you can edit the settings using: git config --global --edit
# Initialize the git repository
git init
# Add the remote repository
git remote add -f origin https://getshiftingcom@dev.azure.com/getshiftingcom/Documentation/_git/knowledge
# Enable sparse checkout
git sparse-checkout init
git sparse-checkout set dokuwiki/pages dokuwiki/media
git sparse-checkout list
dokuwiki/media
dokuwiki/pages
# Pull the latest changes from the remote repository
git pull origin main

Configure Dokuwiki for git backed pages

To make dokuwiki aware of working with git as the backend for the pages and media, we need to install the gitbacked plugin:

Test git backed dokuwiki

Troubleshooting git backed dokuwiki

If you're working on the dokuwiki and the git backend at the same time you might run into problems with the git repository. The best advice is to not edit pages in dokuwiki and git at the same time, but if you've done so, you could run into any of the following issues:

Always when you want to work with git on the server, follow the following steps:

cd /opt/bitnami/apache/htdocs/data/gitrepo
sudo su daemon
git status
# Check the remote repository
git remote -v
# Check git settings
git config --global --list
# Check the sparse checkout settings
git sparse-checkout list
# Pull the latest changes from the remote repository
git pull origin main

Setup Route53, Certificate Manager and CloudFront

Now we want to make sure the wiki is securely accessible by using a certificate. Th easiest way is to use AWS Certificate Manager, Route53 and CloudFront to setup the certificate and the domain name.

Route 53 - origin.getshifting.com

This was already done when we created the instance for easy access to the instance, but this is how it's done. By now we will also use a fixed IPv4 address for the orgin.

Now we need to update the origin.getshifting.com A record in Route 53 to point to the new static IP address:

Setup LetsEncrypt

Because cloudfront needs a certificate to be running on the local instance, we will create letsencrypt certificates using the bncert-tool that comes with the bitnami stack. This will also setup the cron job to automatically renew the certificate.

Any changes and details can be reviewed in the following files:

Backup files:
* /opt/bitnami/apache/conf/httpd.conf.back.202506011407
* /opt/bitnami/apache/conf/bitnami/bitnami.conf.back.202506011407
* /opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf.back.202506011407
 
Find more details in the log file:
 
/tmp/bncert-202506011407.log
The certificate can be reviewed by going to https://origin.getshifting.com in a private browser tab and clicking on the lock icon in the address bar.

Setup Certificate Manager

Now we must create a certificate for the domain name wiki.getshifting.com, which will be used by cloudfront.

Create CloudFront Distribution

Now we can create a CloudFront distribution to serve the dokuwiki pages securely using the certificate we just created.

Wait for the distribution to be deployed, before continuing. After deployment, check the behavior tab. Dokuwiki works better if caching is only enabled for the media files, so we will change the default behavior (Default (*)) to not caching:

Note: With the latest dokuwiki version I kept having trouble with logging in. I had to create CloudFront Invalidations (/*) all the time to be able to log in. I removed all behaviors except for the default. After that it started working again.

Once you've saved the changes the distribution needs to be deployed again, which can take a few minutes. Note that, depending on already cached pages it might take a while for dokuwiki to work completely as expected.

Create Route 53 Alias Record

Change wiki a record to alias to point to cloudfront distribution

Backup

As all of the dokuwiki data is in the git repository, we only need a backup of the lightsail instance itself:

Next Steps

The next step is to configure monitoring using AWS CloudWatch, which will allow us to monitor the instance and the dokuwiki pages. This will include setting up the CloudWatch agent, configuring log files, and creating a dashboard to visualize the metrics: How to setup and configure Cloudwatch for an AWS Lightsail instance.

Useful Command references

Useful DokuWiki Directories

Known Issues