KaliLinux 2018.2: Install DokuWiki for wiki software

This article will describe installing DokuWiki.

1 Install DokuWiki

  • This article uses default SSL/TLS certicication file for https. Please change your SSL/TLS certification file.
  • If you use http instead of https, change 443 to 80 and delete SSLXXX directive in /etc/httpd/conf.d/dokuwiki.conf.
#!/bin/sh -e


PHP_VERSION=7.2
[ -z "${DOKUWIKI_PASSWD}" ] && DOKUWIKI_PASSWD=dokuwiki

dokuwiki_install()
{
  cat <<EOF | sudo debconf-set-selections
dokuwiki dokuwiki/wiki/password password ${DOKUWIKI_PASSWD}
dokuwiki dokuwiki/wiki/confirm password ${DOKUWIKI_PASSWD}
dokuwiki dokuwiki/system/purgepages boolean false
EOF

  sudo apt install -y dokuwiki

  # BUG: DokuWiki upstream has fixed this error.
  sudo cp /usr/share/dokuwiki/lib/exe/css.php \
       /usr/share/dokuwiki/lib/exe/css.php.orig
  sudo sed -i /usr/share/dokuwiki/lib/exe/css.php \
-e 's;$less->importDir\[\] = DOKU_INC;$less->importDir = array(DOKU_INC);g'
}

apache_install()
{
  sudo apt install -y \
       apache2 libapache2-mod-php${PHP_VERSION} \
       php${PHP_VERSION}-xml php${PHP_VERSION}-mbstring

  sudo chown -R www-data:www-data /usr/share/dokuwiki

  cat <<EOF | sudo tee /etc/apache2/sites-available/dokuwiki.conf
<VirtualHost _default_:443>
  SSLEngine on
  SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

  Alias /dokuwiki /usr/share/dokuwiki

  <Directory /usr/share/dokuwiki>
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
EOF

  sudo a2enmod ssl
  sudo a2enmod php${PHP_VERSION}
  sudo a2ensite dokuwiki
  sudo systemctl enable apache2
  sudo systemctl restart apache2
}

dokuwiki_main()
{
  dokuwiki_install
  apache_install
}

dokuwiki_main

2 Access to DokuWiki

Access to the following URL. Accept this page's certification to browser.

https://<server>/dokuwiki

DokuWiki page is displayed. Login to DokuWiki with inputing admin to user and DOKUWIKI_PASSWD value to password.

0001_Dokuwiki.png