CentOS 7: Install DokuWiki

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

set -e

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

centos_install_dokuwiki()
{
  # BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1372948
  R=https://bugzilla.redhat.com
  P="${R}/attachment.cgi?id=1251789&action=diff&context=patch&collapsed=&headers=1&format=raw"

  F=https://dl.fedoraproject.org/pub/fedora
  D=${F}/linux/releases/25/Everything/source/tree/Packages/d
  wget -q ${D}/dokuwiki-0-0.27.20150810a.fc24.src.rpm

  sudo yum-builddep -y dokuwiki-0-0.27.20150810a.fc24.src.rpm
  rpm -i dokuwiki-0-0.27.20150810a.fc24.src.rpm
  rm -f dokuwiki-0-0.27.20150810a.fc24.src.rpm

  cd ~/rpmbuild/SPECS
  wget -q "${P}" -O - | patch -p0
  cd ..
  rpmbuild -ba SPECS/dokuwiki.spec
  cd ..

  pkgs=$(find ~/rpmbuild/RPMS -type f)
  sudo yum install -y epel-release
  # shellcheck disable=SC2086
  sudo yum localinstall -y ${pkgs}
  rm -rf ~/rpmbuild

  # Add ACL and admin user.
  passwd=$(printf "%s" "${DOKUWIKI_PASSWD}" | md5sum -b | cut -d' ' -f1)
  echo "admin:${passwd}:::admin,user" | \
    sudo tee /etc/dokuwiki/users.auth.php
  cat <<EOF | sudo tee /etc/dokuwiki/local.php
<?php
\$conf['useacl'] = 1;
\$conf['superuser'] = '@admin';
EOF
}

centos_install_apache()
{
  sudo yum install -y mod_ssl

  sudo mv /etc/httpd/conf.d/dokuwiki.conf \
       /etc/httpd/conf.d/dokuwiki.conf.orig

  cat <<EOF | sudo tee /etc/httpd/conf.d/dokuwiki.conf
<VirtualHost _default_:443>
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/localhost.crt
  SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

  Alias /dokuwiki /usr/share/dokuwiki

  <Directory /usr/share/dokuwiki>
    Require all granted
  </Directory>

  <Directory /usr/share/dokuwiki/inc>
    Require all denied
  </Directory>

  <Directory /usr/share/dokuwiki/inc/lang>
    Require all denied
  </Directory>

  <Directory /usr/share/dokuwiki/lib/_fla>
    Require all denied
  </Directory>

  <Directory /etc/dokuwiki>
    Require all denied
  </Directory>
</VirtualHost>
EOF

  sudo systemctl enable httpd
  sudo systemctl restart httpd
  sudo firewall-cmd --add-service=https --permanent
  sudo firewall-cmd --reload
}

centos_main()
{
  centos_install_dokuwiki
  centos_install_apache
}

centos_main

2 Access to DokuWiki

Access to the following URL.

https://<server>/dokuwiki

Because the chrome does not have this page's certification, the crome warns the following and cannot to access to this page. You need to click "ADVANCED" and "Proceed to <server> (unsafe)". The other browser will needs the similar way.

0001_YourConnectionIsNotPrivate.png

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

0002_DokuWiki.png