How to install and configure DokuWiki on CentOS 7 with PHP 7.1

Cpanel/Whm License $3/mo Plesk License $10/mo Cloudlinux License $5/mo

(: 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.{text-align:left} img{margin:0 auto 0 0}

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
sudo rpm -Uvh
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/ > /etc/httpd/conf.d/addModule-mod_rewrite.conf

Now download and install DokuWiki

wget -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 !mod_authz_host>
        Order allow,deny
        Deny from all

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

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

DocumentRoot "/var/www/html"

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

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

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:


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.{text-align:left} img{margin:0 auto 0 0}

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More