DokuWiki is a free, open-source and versatile wiki software that does not require a database. It is simple, easy to use and requires few resources. It works with simple text and allows users to create and edit pages via a web browser. It comes with a large number of plugins that help you utilize a wide range of use cases beyond a traditional wiki. It has built-in access control and authentication connections that make it useful for enterprise use.

Features

  • Native WYSIWYG support for markup.
  • SEO friendly.
  • Flexible CSS framework.
  • Wide range of extensions.
  • Support for over 50 languages.
  • Device-independent.

In this tutorial we will show you how to install Dokuwiki on CentOS 8 and secure it with Let’s Encrypt free SSL.

Requirements

  • A server running CentOS 8.
  • A valid domain name that points to your IP address.
  • A root password is configured on your server.

Install HTTP and PHP

Dokuwiki runs on the web server and is written in the PHP language. Therefore, you need to install HTTP, PHP and other PHP extensions on your system. You can install them all with the following command:

dnf install httpd php php-zip php-gd php-xml php-json curl unzip wget git -y

Once all packages are installed, start the HTTP service and enable it so that it starts after a system reboot:

systemctl start httpd
 systemctl enable httpd

Next, open the php.ini file and make some settings:

nano /etc/php.ini

Change the value according to your requirements:

memory_limit = 128M
post_max_size = 32M
upload_max_filesize = 8M
max_execution_time = 300
date.timezone = Asia/Kolkata

Save and close the file when you’re done.

Install Dokuwiki

First you need to download the latest version of Dokuwiki from the official website. You can download it with the following command:

wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

After downloading, unzip the downloaded file with the following command:

tar -xvzf dokuwiki-stable.tgz

Next, move the unzipped directory to the HTTP root directory:

mv dokuwiki-2018-04-22b /var/www/html/dokuwiki

Next, give the dokuwiki the correct permissions with the following command:

chown -R apache:apache /var/www/html/dokuwiki/
 chmod -R 775 /var/www/html/dokuwiki/

Once you’re done, you can proceed to the next step.

Configure Apache for Dokuwiki

Next, you need to create an Apache configuration file to operate Dokuwiki. You can create it with the following command:

nano /etc/httpd/conf.d/dokuwiki.conf

Paste the following lines:

        ServerName    dokuwiki.linuxbuz.com
        DocumentRoot  /var/www/html/dokuwiki

        
            
               	Require all denied
            
            
                Order allow,deny
               	Deny from all
            
        

        ErrorLog   /var/log/httpd/dokuwiki_error.log
        CustomLog  /var/log/httpd/dokuwiki_access.log combined

Save and close the file when you’re done. Then check Apache for syntax errors with the following command:

apachectl configtest

If everything is OK, you should get the following output:

Syntax OK

Finally, restart the HTTP service to apply the changes:

systemctl restart httpd

Secure Dokuwiki with Let’s Encrypt SSL

Dokuwiki is now installed and configured. Next, we recommend securing your Dokuwiki site with Let’s Encrypt SSL. First you need to install the Certbot client on your system. Certbot is a Let’s Encrypt client that allows you to download the SSL from the Let’s Encrypt website and configure the Apache web server to use the downloaded SSL.

You can install the Certbot with the following command:

wget https://dl.eff.org/certbot-auto
 mv certbot-auto /usr/local/bin/certbot-auto
 chown root /usr/local/bin/certbot-auto
 chmod 0755 /usr/local/bin/certbot-auto

Now run the following command to obtain and install an SSL certificate for your Dokuwiki website.

certbot-auto --apache -d dokuwiki.linuxbuz.com

The above command will first install all required dependencies on your server. After installation, you will be asked to enter an e-mail address and accept the terms of use (see below):

Note: If an SSL error occurs, restart the httpd service and run the above command again.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for dokuwiki.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/httpd/conf.d/dokuwiki-le-ssl.conf
Deploying Certificate to VirtualHost /etc/httpd/conf.d/dokuwiki-le-ssl.conf

Next, select whether or not to redirect HTTP traffic to HTTPS and remove HTTP access.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Type 2 and press Enter to start the installation process. Once the installation has been successfully completed, you should receive the following output:

Redirecting vhost in /etc/httpd/conf.d/dokuwiki.conf to ssl vhost in /etc/httpd/conf.d/dokuwiki-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://dokuwiki.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=dokuwiki.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/dokuwiki.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/dokuwiki.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-05-10. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. To non-interactively renew *all*
   of your certificates, run "certbot-auto renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Configure Firewall and SELinux

Next, you need to open ports 80 and 443 via the firewall. You can allow them with the following command:

firewall-cmd --permanent --add-port=80/tcp
 firewall-cmd --permanent --add-port=443/tcp

Next, you need to reload the firewalld to apply the changes:

firewall-cmd --reload

By default, SELinux is enabled in CentOS 8. Therefore, you need to configure SELinux to allow Dokuwiki remotely.

First install the Policy Controll tool with the following command:

dnf install policycoreutils-python-utils -y

Next, run the following commands to configure the SELinux context:

semanage fcontext -a -t httpd_sys_rw_content_t "https://vitux.com/var/www/html/dokuwiki/conf(/.*)?"
 restorecon -Rv /var/www/html/dokuwiki/conf
 restorecon -Rv /var/www/html/dokuwiki/data
 setsebool -P httpd_can_network_connect on
 setsebool -P httpd_can_sendmail on
 setsebool -P httpd_unified 1
 semanage fcontext -a -t httpd_sys_rw_content_t "https://vitux.com/var/www/html/lib/plugins(/.*)?"
 restorecon -Rv /var/www/html/dokuwiki/lib/plugins
 semanage fcontext -a -t httpd_sys_rw_content_t "https://vitux.com/var/www/html/dokuwiki/lib/tpl(/.*)?"
 restorecon -Rv /var/www/html/dokuwiki/lib/tpl

Finally, restart the Apache server to apply the changes:

systemctl restart httpd

Access Dokuwiki

Now open your web browser and enter the URL https://dokuwiki.linuxbuz.com/install.php. You will be redirected to the following page:

How to install DokuWiki on CentOS centos linux

Enter your wiki name, your superuser name and your password and click on the Save button. You should see the following page:

How to install DokuWiki on CentOS centos linux

Click on your new DokuWiki and you should see the following page:

How to install DokuWiki on CentOS centos linux

Next, click on the Log in button in the top right-hand corner of the window. You should see the following page:

How to install DokuWiki on CentOS centos linux

Enter your Superadmin username and password and click the Login button. You should see the following page:

How to install DokuWiki on CentOS centos linux

Conclusion

Congratulations! You have successfully installed Dokuwiki on CentOS 8 and secured it with Let’s Encrypt free SSL. Now you can easily create your wiki page via a web browser. If you have any further questions, please feel free to contact me.