Building DokuWiki on CentOS 7

I seem to be doing a lot of these posts now.

I’ve been experimenting with the idea of setting up a Wiki at home. I’ve got a “Documents” folder where everything …documenty… lives, but its gradually getting harder and harder to find things as it grows. So now I’m trialing having my content in a Wiki for easier access.

DokuWiki was first in line to be tested, as it has Markdown support (with plugins). Mediawiki used to be my first choice, but I really don’t like how unintuitive the editor is in it. I have to keep re-learning after I don’t add content for a week.

Here’s what I did to set it up DokuWiki:

Part 1: Build

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## Provision new CentOS 7 machine
# Language: English (US)
# Timezone: Australia/Sydney
# Software Selection: Minimal
# Automatic Partitioning

## SSH to Server

## Turn off SELinux
sed -i 's/enforcing/disabled/g' /etc/selinux/config

## Update the Server
yum update -y

## Install Prerequisites (php-ldap only needed if you're using LDAP authentication)
yum install yum-cron httpd php php-gd php-ldap openssl mod_ssl wget -y

## Turn on Auto Updates
sed -i 's/apply_updates = no/apply_updates = yes/g' /etc/yum/yum-cron.conf

## Firewall Configuration
firewall-cmd --permanent --zone=internal --change-interface=eth0
firewall-cmd --permanent --zone=internal --add-service=http
firewall-cmd --permanent --zone=internal --add-service=ssh
firewall-cmd --permanent --zone=internal --add-service=https
firewall-cmd --reload

## Restart for SELinux change to take effect
shutdown -r now

## Enable httpd
systemctl enable httpd.service

## Enable mod_rewrite
echo "LoadModule rewrite_module modules/mod_rewrite.so" >> /etc/httpd/conf/httpd.conf

## Download and Install DokuWiki
wget http://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
# unpack the tar
tar -xzf dokuwiki-stable.tgz
# remove the tar
rm -f dokuwiki-stable.tgz
# move the dokuwiki folder to the web server (the * is why we removed the tar)
mv dokuwiki-* /var/www/html/dokuwiki
# set permissions for dokuwiki
chown -R apache:root /var/www/html/dokuwiki
chmod -R 664 /var/www/html/dokuwiki/
find /var/www/html/dokuwiki/ -type d -exec chmod 775 {} \;

## Start httpd
systemctl start httpd.service

Part 2: Setup

Now you should be able to browse to http://{site}/dokuwiki/install.php. There will be a security warning, ignore it for now.

Configure the instance how you want it, and then move on to the next part.

Part 3: Cleanup

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## SSH to Server

## Delete the Install.php file
rm -f /var/www/html/dokuwiki/install.php

## Move the Data Directory
mkdir /var/www/dokudata
mv /var/www/html/dokuwiki/data/ /var/www/dokudata/
mv /var/www/html/dokuwiki/conf/ /var/www/dokudata/
mv /var/www/html/dokuwiki/bin/ /var/www/dokudata/

## Tell DokuWiki about the new directories
touch /var/www/html/dokuwiki/inc/preload.php
echo "<?php" >> /var/www/html/dokuwiki/inc/preload.php
echo "// DO NOT use a closing php tag. This causes a problem with the feeds," >> /var/www/html/dokuwiki/inc/preload.php
echo "// among other things. For more information on this issue, please see:" >> /var/www/html/dokuwiki/inc/preload.php
echo "// http://www.dokuwiki.org/devel:coding_style#php_closing_tags" >> /var/www/html/dokuwiki/inc/preload.php
echo "" >> /var/www/html/dokuwiki/inc/preload.php
echo "define('DOKU_CONF','/var/www/dokudata/conf/');" >> /var/www/html/dokuwiki/inc/preload.php
echo "\$conf['savedir'] = '/var/www/dokudata/data/';" >> /var/www/dokudata/conf/local.php

## Set permissions for the new directories
chown -R apache:root /var/www/html/dokuwiki
chmod -R 664 /var/www/html/dokuwiki/
find /var/www/html/dokuwiki/ -type d -exec chmod 775 {} \;
chown -R apache:root /var/www/dokudata
chmod -R 664 /var/www/dokudata/
find /var/www/dokudata/ -type d -exec chmod 775 {} \;

Part 4: Configuration

The site should be functioning properly now, and ready to be configured at http://{site}/dokuwiki/