(Last Updated On: March 2, 2018)

In this tutorial, I’m going to work you through all the steps needed to have the latest version of DokuWiki up and running on CentOS 7 base system.

DokuWiki is a simple to use and highly versatile Open Source wiki software that doesn’t require a database. The fact that DokuWiki doesn’t use database makes it easier to do maintenance and backups

DokuWiki also has built-in access controls and external authentication connectors which makes it useful in the enterprise context. Also, the large number of plugins contributed by its vibrant community allow for a broad range of use cases beyond a traditional wiki.

Install httpd web server and php packages

To install Apache web server on CentOS 7, use the following command:

sudo yum install httpd* -y

If using firewalld, make sure http port is open on the firewall, also add https is using ssl encryption.

sudo firewall-cmd --permanent --zone=public --add-service={http,https}
sudo firewall-cmd --reload

Now install php 7 and php-gd

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum clean all
sudo yum makecache fast
sudo yum install -y mod_php71w php71w-cli php71w-common php71w-gd php71w-mbstring ph p71w-mcrypt php71w-mysqlnd php71w-xml

Check php version:

# php -v

PHP 7.1.4 (cli) (built: Apr 15 2017 08:07:03) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

By default, apache rewrite rule is enabled by default on CentOS 7, if you need to redo, just type:

echo LoadModule rewrite_module modules/mod_rewrite.so > /etc/httpd/conf.d/addModule-mod_rewrite.conf

Now download and install DokuWiki

wget https://download.dokuwiki.org/out/dokuwiki-c5525093cf2c4f47e2e5d2439fe13964.tgz -O dokuwiki.tgz
sudo tar zxvf dokuwiki.tgz -C /var/www/html/ --strip-components=1

Above command will download and extract dokuwiki archive to /var/www/html. Replace the path with a valid one if you need to.

Configure httpd and DokuWiki

Next thing to do is secure DokuWiki using .htaccess.

cd /var/www/html
cp .htaccess.dist .htaccess

Add .htaccess Restriction

I’m using the default settings which look similar to below:

# cat .htaccess

<Files ~ "^([\._]ht|README$|VERSION$|COPYING$)">
    <IfModule mod_authz_host>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_host>
        Order allow,deny
        Deny from all
    </IfModule>
</Files>

## Don't allow access to git directories
<IfModule alias_module>
    RedirectMatch 404 /\.git
</IfModule>

Configure httpd.conf

Now tell Apache to restrict access to /var/www/html using .htaccess file defined

# vim /etc/httpd/conf/httpd.conf

Modify as below:

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    Require all granted
</Directory>


# Further restrict access to the default document root:
<Directory "/var/www/html">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
</Directory>

Set permissions for DokuWiki DocumentRoot:

sudo chown -R apache:apache /var/www/html

Configure SELinux

For SELinux in enforcing mode, run the following commands

yum install policycoreutils-python
chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/conf/
chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/data/
semanage fcontext -a -t httpd_sys_rw_content_t /var/www/html/data/
semanage fcontext -a -t httpd_sys_rw_content_t /var/www/html/conf
restorecon -v /var/www/html/conf/
restorecon -v /var/www/html/data/
setsebool -P httpd_can_network_connect on

Start httpd daemon

systemctl start httpd && systemctl enable httpd

You’re done with the installation section, the next thing is to configure DokuWiki.

Open your browser and go to:

http://dokuwiki-server-hostname/install.php

Answer initial questions accordingly, set superuser, enable ACL and login to DokuWiki dashboard.

That’s all. You can then add skins and plugins available on the admin dashboard.