How to Install DokuWiki on Ubuntu 20.04 LTS

DokuWiki is a free, open-source, and most versatile wiki application written in PHP. It is simple and light-weight that uses a simple file format to store its data, so it does not require any database. It is known for its clean and readable syntax and allows you to easily scale and optimize using many advanced features. You can create your personal or business websites by just uploading its content to your server. It comes with a rich set of features including, WYSIWYG support, SEO friendly, built-in access controls, and authentication connectors, flexible CSS framework, and many more.

In this tutorial, we will show you how to install DokuWiki with Apache and Letsencrypt SSL certificate on Ubuntu 20.04.

Prerequisites

  • A server running Ubuntu 20.04.
  • A valid domain name pointed with your server.
  • A root password is configured on your server.

Update the System Packages

Before starting, it is recommended to update your system packages to the latest version. You can do it with the following command:

apt-get update -y
apt-get upgrade -y

Once your system is updated, restart it to implement the changes.

Install Apache and PHP

DokuWiki is written in PHP and runs on the webserver. So you will need to install the Apache webserver, PHP and other PHP libraries to your system. You can install all of them by running the following command:

apt-get install apache2 php php-gd php-xml php-json -y

Once all the packages are installed, start the Apache service and enable it to start at boot with the following command:

systemctl start apache2
systemctl enable apache2

Once you are done, you can proceed to the next step.

Download DokuWiki

First, go to the DokuWiki official download page and download the latest version of the DokuWiki with the following command:

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

Once the download is completed, create a DokuWiki directory inside the Apache web root directory and extract the DokuWiki:

mkdir /var/www/html/dokuwiki
tar -xvzf dokuwiki-rc.tgz -C /var/www/html/dokuwiki/ --strip-components=1

Next, copy the sample .htaccess file with the following command:

cp /var/www/html/dokuwiki/.htaccess{.dist,}

Next, change the ownership of the dokuwiki to www-data:

chown -R www-data:www-data /var/www/html/dokuwiki

Once you are finished, you can proceed to the next step.

Configure Apache for DokuWiki

Next, create an Apache virtual host configuration file to serve the DokuWiki website:

nano /etc/apache2/sites-available/dokuwiki.conf

Add the following lines:

<VirtualHost *:80>
        ServerName    dokuwiki.linuxbuz.com      
        DocumentRoot  /var/www/html/dokuwiki

        <Directory ~ "/var/www/html/dokuwiki/(bin/|conf/|data/|inc/)">
            <IfModule mod_authz_core.c>
                AllowOverride All
                Require all denied
            </IfModule>
            <IfModule !mod_authz_core.c>
                Order allow,deny
                Deny from all
            </IfModule>
        </Directory>

        ErrorLog   /var/log/apache2/dokuwiki_error.log
        CustomLog  /var/log/apache2/dokuwiki_access.log combined
</VirtualHost>

Save and close the file when you are finished. Then, enable the DokuWiki site and reload the Apache service with the following command:

a2ensite dokuwiki.conf
systemctl reload apache2

At this point, the Apache web server is configured to serve the DokuWiki site. You can now proceed to install Let's Encrypt SSL on your website.

Secure DokuWiki with Let's Encrypt SSL

First, you will need to install the Certbot client in your system. The Certbot is an easy-to-use client that fetches a certificate from Let's Encrypt an open certificate authority launched by the EFF, Mozilla, and others—and deploys it to a web server. Using the Certbot Let's Encrypt client you can easily download, install and renew the SSL certificate for your domain.

You can install the Certbot with the following command:

apt-get install certbot python3-certbot-apache -y

Once the Certbot client has been installed successfully, run the following command to install the Let's Encrypt SSL for your website:

certbot --apache -d dokuwiki.linuxbuz.com

You will be asked to provide your valid email and accept the term of service as shown below:

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
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/dokuwiki-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/dokuwiki-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/dokuwiki-le-ssl.conf

Next, select whether or not to redirect HTTP traffic to HTTPS or configure Nginx to redirect all traffic to secure HTTPS access  as shown in the following output:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing 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 hit Enter to start the process. Once the installation is completed, you should get the following output:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/dokuwiki.conf to ssl vhost in /etc/apache2/sites-available/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-09-05. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - 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

At this point, your Dokuwiki site is secured with Let's Encrypt SSL. You can now access your site securely using HTTPS protocol.

Access the DokuWiki

Now, open your web browser and type the URL https://dokuwiki.linuxbuz.com/install.php. You should see the DokuWiki installation screen:

DokuWiki Installer

Choose license

Provide your wikiname, admin username, password, email, choose your policy and click on the Save button. You will be redirected to the following page:

Finished configuration

Click on "you new DokuWiki". You should see the following screen:

DokuWiki welcome page

Click on the Login button. You will be redirected to the DokuWiki login screen as shown below:

DokuWiki Login

Provide your admin username, password and click on the Log In button. You should see the DokuWiki dashboard in the following screen:

DokuWiki admin dashboard

Setting Up Let's Encrypt SSL Certificate Auto-Renewal

By default, Let’s Encrypt certificates are valid for 90 days. So, you will need to set up a cron job to auto-renew SSL certificate. It is safe to create a cron job that runs every week or even every day.

If you want to renew the SSL certificate manually, run the following command:

certbot renew --dry-run

You can set up cron job to auto-renew SSL certificate every day at 10:00 AM by editing following file:

crontab -e

Add the following line:

00 10 * * *   root /usr/bin/certbot renew >/dev/null 2>&1

Save and close the file, when you are finished.

Conclusion

Congratulations! you have successfully installed DokuWiki and secured it with Let's Encrypt SSL on Ubuntu 20.04. You can also extend your DokuWiki using theme, plugins and templates. Feel free to ask me if you have any questions.

Share this page:

Suggested articles

0 Comment(s)

Add comment