DokuWiki is a free, open-source, simple, and lightweight wiki software that allows you to create and edit a website from your web browser. It is a powerful application written in PHP that stores data in a file instead of a database. It has many built-in features allow you to scale and optimize your website easily. It is becoming increasingly popular due to its clean and readable syntax, easy maintenance, data backup, and integration.
This article will show you how to install DokuWiki with Apache and Let’s Encrypt SSL on Ubuntu 22.04.
Requirements
- A server running Ubuntu 22.04.
- A valid domain name is directed to the IP of your server.
- A root password is configured on the server.
First steps
Before you get started, you should update and upgrade all system packages to the latest version. You can update them by running the following command:
apt update -y apt upgrade -y
Once all packages are updated, you can proceed to the next step.
Install Apache and PHP
First, you must install Apache, PHP, and other required extensions on your server. You can install them by running the following command:
apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-imap php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-bcmath php-ldap php-zip php-curl unzip curl -y
Once all the packages are installed, start the Apache service and enable it so that it starts when the system reboots:
systemctl start apache2 systemctl enable apache2
Once you are done, you can proceed to the next step.
Install DokuWiki on Ubuntu 22.04
Next, go to the DokuWiki download page and download the latest version of DokuWiki with the following command:
wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
Once the download is complete, create a directory for DokuWiki within the Apache web root directory:
mkdir /var/www/html/dokuwiki
Unzip the downloaded file into the DokuWiki directory using the following command:
tar -xvzf dokuwiki-stable.tgz -C /var/www/html/dokuwiki/ --strip-components=1
Next, copy some necessary files with the following command:
cp /var/www/html/dokuwiki/.htaccess{.dist,}
Next, you need to set the ownership rights for the DokuWiki directory:
chown -R www-data:www-data /var/www/html/dokuwiki
When you are done with that, you can proceed to the next step.
Configure Apache for DokuWiki
Next, you need to create a configuration file for the Apache virtual host to host DokuWiki. You can create it with the following command:
nano /etc/apache2/sites-available/dokuwiki.conf
Paste the following lines:
ServerName dokuwiki.example.com DocumentRoot /var/www/html/dokuwiki AllowOverride All Require all denied Order allow,deny Deny from all ErrorLog /var/log/apache2/dokuwiki_error.log CustomLog /var/log/apache2/dokuwiki_access.log combined
Save and close the file and activate the configuration file for the Apache virtual host with the following command:
a2ensite dokuwiki.conf
Next, reload the Apache service so that the changes are applied.
systemctl reload apache2
You can also check the Apache status with the following command:
systemctl status apache2
You will get the following output:
? apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-11-12 13:55:11 UTC; 13s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 16193 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 16197 (apache2) Tasks: 6 (limit: 464122) Memory: 14.2M CGroup: /system.slice/apache2.service ??16197 /usr/sbin/apache2 -k start ??16198 /usr/sbin/apache2 -k start ??16199 /usr/sbin/apache2 -k start ??16200 /usr/sbin/apache2 -k start ??16201 /usr/sbin/apache2 -k start ??16202 /usr/sbin/apache2 -k start Nov 12 13:55:10 ubuntu22041 systemd[1]: Starting The Apache HTTP Server...
Enable SSL on DokuWiki
Securing your wiki site with a Let’s Encrypt SSL certificate is a good idea. You need to install the Certbot client in your system to do this.
You can install the Certbot with the following command:
apt-get install certbot python3-certbot-apache -y
Once the Certbot client has been successfully installed, run the following command to install the Let’s Encrypt SSL certificate for your website:
certbot --apache -d dokuwiki.example.com
You will be asked to enter your valid e-mail address and accept the terms of use (see 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.example.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 to redirect HTTP traffic to HTTPS or configure Nginx to redirect all traffic to secure HTTPS access, as shown in the output below:
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 press Enter to start the process. Once the installation is complete, you should receive 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.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=dokuwiki.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/dokuwiki.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/dokuwiki.example.com/privkey.pem Your cert will expire on 2023-02-12. 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 website is secured with Let’s Encrypt SSL. You can now securely access your website using the HTTPS protocol.
Accessing the DokuWiki web interface
Now open your web browser and access DokuWiki via the URL https://dokuwiki.example.com/install.php. You should see the DokuWiki installation screen:
Enter your wiki name, admin username, password and email address, select your policy and click the Save button. You will be redirected to the following page:
Click on “Your new DokuWiki”. You should see the following screen:
Click on the ” Login” button. You will be redirected to the DokuWiki login screen (see below):
Enter your admin username and password and click the Login button. On the following screen you should see the DokuWiki dashboard:
Conclusion
Congratulations! You have successfully installed DokuWiki and secured it with Let’s Encrypt SSL on Ubuntu 22.04. You can now host your own wiki site with DokuWiki. If you have any questions, please feel free to contact me.