How To Install DokuWiki on Debian 12
In this tutorial, we will show you how to install DokuWiki on Debian 12. DokuWiki is a popular open-source wiki software that doesn’t require a database. It‘s written in PHP, making it an ideal choice for creating and managing documentation, collaborative projects, and more. This software is known for its clean and readable syntax, which simplifies the process of content creation.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the DokuWiki on a Debian 12 (Bookworm).
Prerequisites
- A server running one of the following operating systems: Debian 12 (Bookworm).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- You will need an active internet connection to download the DokuWiki package.
- A domain name pointed to your server IP (optional but recommended for a production environment).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install DokuWiki on Debian 12 Bookworm
Step 1. First, log in to your Debian 12 system. Update the package lists for upgrades and new package installations using the following command:
sudo apt update sudo apt upgrade
This command first updates the list of available packages and their versions then upgrades the installed packages to their latest versions.
Step 2. Installing LEMP Stack.
Before starting this tutorial, the LEMP server must be installed on your server. If you do not have LEMP Stack installed, you can follow our guide here.
Step 3. Installing DokuWiki on Debian 12.
Now download the latest stable version of DokuWiki:
cd /var/www/html/ sudo wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
Extract the DokuWiki archive:
sudo tar xzvf dokuwiki-stable.tgz
Rename the extracted directory to ‘dokuwiki
‘:
sudo mv dokuwiki-*/ dokuwiki/
Step 4. Configuring MySQL/MariaDB.
Start by logging into MySQL:
sudo mysql -u root -p
Create a database for DokuWiki:
CREATE DATABASE dokuwiki;
Next, create a user and grant all privileges on the DokuWiki database:
CREATE USER 'dokuwikiuser'@'localhost' IDENTIFIED BY 'your-strong-password'; GRANT ALL PRIVILEGES ON dokuwiki.* TO 'dokuwikiuser'@'localhost'; FLUSH PRIVILEGES;
Exit MySQL:
EXIT;
Step 5. Configuring Nginx for DokuWiki.
Create a new Nginx server block file:
sudo nano /etc/nginx/sites-available/dokuwiki
Add the following configuration:
server { listen 80; listen [::]:80; root /var/www/html/dokuwiki; index doku.php; server_name your_domain.com www.your_domain.com; location / { try_files $uri $uri/ @dokuwiki; } location @dokuwiki { rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; rewrite ^/(.*) /doku.php?id=$1&$args last; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
Save and close the file. Enable the new server block by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/dokuwiki /etc/nginx/sites-enabled/
Test Nginx configuration for syntax errors:
sudo nginx -t
If the test is successful, restart Nginx:
sudo systemctl restart nginx
Step 6. Securing DokuWiki with SSL.
If you’re setting up a production environment, it’s recommended to secure your DokuWiki with SSL. Install Let’s Encrypt Certbot:
sudo apt install certbot python3-certbot-nginx
Obtain and install an SSL certificate:
sudo certbot --nginx -d your_domain.com -d www.your_domain.com
Follow the prompts and choose to redirect HTTP traffic to HTTPS.
Step 7. Configure Firewall.
Now we set up an Uncomplicated Firewall (UFW) with Nginx to allow public access on default web ports for HTTP and HTTPS:
sudo ufw allow OpenSSH sudo ufw allow 'Nginx HTTP' sudo ufw allow 'Nginx HTTPS' sudo ufw enable
You can check the status of UFW and see the rules currently in effect by typing:
sudo ufw status
Step 8. Accessing DokuWiki Web Interface.
Now, open a web browser and navigate to your domain or IP address. You should see the DokuWiki installation page. Follow the prompts to set up an admin account and adjust settings.
Congratulations! You have successfully installed DokuWiki. Thanks for using this tutorial to install the latest version of the DokuWiki on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official DokuWiki website.