How to install and configure DokuWiki in RHEL7

Let’s create the VM first:

[root@rhel7 ~]# virt-install \
> --hvm \
> --name wiki \
> --ram 1024 \
> --disk path=/kvm/wiki.img,size=50 \
> --vcpus 1 \
> --os-type linux \
> --os-variant rhel7 \
> --network bridge=virbr0 \
> --graphics none \
> --location 'http://192.168.122.3/rhel7' \
> --extra-args "ks=http://192.168.122.3/ksfiles/rhel7-minimal-ks.cfg \
> console=tty0 console=ttyS0,115200 SERVERNAME=wiki.jefrey.io IPADDR=192.168.122.9"

Starting install...
...
...
[root@wiki ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.9  netmask 255.255.255.0  broadcast 192.168.122.255
        inet6 fe80::5054:ff:fe53:e0cd  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:53:e0:cd  txqueuelen 1000  (Ethernet)
        RX packets 3870  bytes 229466 (224.0 KiB)
        RX errors 0  dropped 33  overruns 0  frame 0
        TX packets 224  bytes 19775 (19.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@wiki ~]# 
[root@wiki ~]# vi /etc/sysconfig/network
[root@wiki ~]# cat !$
cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wiki.jefrey.io
GATEWAY=192.168.122.1
GATEWAYDEV=eth0
[root@wiki ~]#

Went to http://download.dokuwiki.org/ for me to have a copy of the installer then I copied it to the server.

[root@wiki ~]# ls -lrt
total 2528
-rw-r--r--. 1 root root    1670 May 31 23:01 anaconda-postinstall.log
-rw-------. 1 root root    5512 May 31 23:01 anaconda-ks.cfg
-rw-r--r--. 1 root root 2573285 May 31 23:19 dokuwiki-90058711fa07482559bd90b004ebed40.tgz
[root@wiki ~]#

Install the necessary packages:

[root@wiki ~]# yum -y install httpd mod_ssl php php-gd
...
Complete!
[root@wiki ~]# 
[root@wiki ~]# vi /etc/httpd/conf.d/options.conf 
[root@wiki ~]# cat !$
cat /etc/httpd/conf.d/options.conf
TraceEnable off

## Disable Signature
ServerSignature Off

## Disable Banner
ServerTokens Prod
[root@wiki ~]#

Although DokuWiki operates with the default PHP settings,
it is recommended to tune your PHP configuration (php.ini) as described here.
At least you should edit your /etc/php.ini and set the following:

# vi /etc/php.ini
expose_php = Off

Restart httpd:

[root@wiki ~]# systemctl restart httpd
[root@wiki ~]# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Sun 2015-05-31 23:46:28 SGT; 11s ago
  Process: 1512 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
 Main PID: 1517 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─1517 /usr/sbin/httpd -DFOREGROUND
           ├─1518 /usr/sbin/httpd -DFOREGROUND
           ├─1519 /usr/sbin/httpd -DFOREGROUND
           ├─1520 /usr/sbin/httpd -DFOREGROUND
           ├─1521 /usr/sbin/httpd -DFOREGROUND
           └─1522 /usr/sbin/httpd -DFOREGROUND

May 31 23:45:48 wiki.jefrey.io systemd[1]: Starting The Apache HTTP Server...
May 31 23:46:08 wiki.jefrey.io httpd[1517]: AH00557: httpd: apr_sockaddr_inf...o
May 31 23:46:08 wiki.jefrey.io httpd[1517]: AH00558: httpd: Could not reliab...e
May 31 23:46:28 wiki.jefrey.io systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@wiki ~]#

Test if PHP module is loaded in Apache using:

[root@wiki ~]# httpd -M | grep php
 php5_module (shared)
[root@wiki ~]#

Configure firewalld for http:

[root@wiki ~]# firewall-cmd --permanent --zone=trusted --add-source=192.168.122.0/24
[root@wiki ~]# firewall-cmd --permanent --zone=public --add-service=http
[root@wiki ~]# firewall-cmd --reload

Virtual hosts configurations:

[root@wiki ~]# vi /etc/httpd/conf.d/vhosts.conf
[root@wiki ~]# cat /etc/httpd/conf.d/vhosts.conf 
# Load my vhosts
IncludeOptional vhosts.d/*.conf
[root@wiki ~]# 
[root@wiki ~]# mkdir /etc/httpd/vhosts.d
[root@wiki ~]# vi /etc/httpd/vhosts.d/wiki.jefrey.io.conf
[root@wiki ~]# 
[root@wiki ~]# cat /etc/httpd/vhosts.d/wiki.jefrey.io.conf 
<VirtualHost 192.168.122.9:80>
    ServerAdmin webmaster@jefrey.io
    DocumentRoot "/var/www/html/dokuwiki"
    ServerName wiki.jefrey.io
    ServerAlias www.wiki.jefrey.io
    ErrorLog "/var/log/httpd/wiki.jefrey.io-error_log"
    CustomLog "/var/log/httpd/wiki.jefrey.io-access_log" combined

    <Directory "/var/www/html/dokuwiki/">
        DirectoryIndex index.php
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
[root@wiki ~]#
[root@wiki ~]# systemctl restart httpd
[root@wiki ~]# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Mon 2015-06-01 12:24:01 SGT; 4s ago
  Process: 2127 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
 Main PID: 2132 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─2132 /usr/sbin/httpd -DFOREGROUND
           ├─2133 /usr/sbin/httpd -DFOREGROUND
           ├─2134 /usr/sbin/httpd -DFOREGROUND
           ├─2135 /usr/sbin/httpd -DFOREGROUND
           ├─2136 /usr/sbin/httpd -DFOREGROUND
           └─2137 /usr/sbin/httpd -DFOREGROUND

Jun 01 12:24:01 wiki.jefrey.io systemd[1]: Starting The Apache HTTP Server...
Jun 01 12:24:01 wiki.jefrey.io httpd[2132]: AH00112: Warning: DocumentRoot [...t
Jun 01 12:24:01 wiki.jefrey.io systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@wiki ~]#

Extract and fix permissions for DokuWiki:

[root@wiki ~]# tar xf dokuwiki-90058711fa07482559bd90b004ebed40.tgz -C /var/www/html
[root@wiki ~]# 
[root@wiki ~]# ls -lrt /var/www/html/
total 8
-rw-r--r--. 1 root root   91 Jun  1 12:05 index.html
drwxr-xr-x. 7 root root 4096 Jun  1 12:25 dokuwiki
[root@wiki ~]# 
[root@wiki ~]# mv /var/www/html/index.html /var/www/html/index.html.old
[root@wiki ~]# 
[root@wiki ~]# chown apache: -R /var/www/html/dokuwiki
[root@wiki ~]# 
[root@wiki ~]# ls -lrt /var/www/html/
total 8
-rw-r--r--. 1 root   root     91 Jun  1 12:05 index.html.old
drwxr-xr-x. 7 apache apache 4096 Jun  1 12:25 dokuwiki
[root@wiki ~]#

Set SELinux:

[root@wiki ~]# setsebool -P httpd_unified on
[ 3205.317418] SELinux:  Context unconfined_u:unconfined_r:sandbox_t:s0-s0:c0.c1023 became invalid (unmapped).
[ 3205.501270] SELinux:  Context system_u:unconfined_r:sandbox_t:s0-s0:c0.c1023 became invalid (unmapped).
[root@wiki ~]# 
[root@wiki ~]# getsebool -a | grep unif
httpd_unified --> on
[root@wiki ~]#

Went to http://wiki.jefrey.io/install.php
and configured the installation; afterwards:

[root@wiki ~]# rm -f /var/www/html/dokuwiki/install.php
[root@wiki ~]# 
[root@wiki ~]# ls -lrtZ /var/www/html/dokuwiki/
-rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 VERSION
-rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 README
-rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 index.php
-rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 feed.php
-rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 doku.php
-rw-rw-r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 COPYING
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 bin
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 data
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 inc
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 lib
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 conf
[root@wiki html]#

DokuWiki is up and running!