Install and Configure DokuWiki on Alibaba Cloud ECS


  1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  2. A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  3. Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  4. Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  5. Set up your server’s hostname and create user with root privileges.

Update Your Ubuntu System

Before proceeding with installation of any kind of package, use the following command to update your Ubuntu system. To execute this command, remember to login from non-root user with sudo privileges. After execution of this command, you will be prompted to Is this ok? Type ‘Y’ and hit Enter.

# sudo apt update && sudo apt upgrade

Install PHP

DokuWiki requires atleast installation of PHP 5.6 or newer version of PHP. In this tutorial, you will install PHP 7.2. To install PHP 7.2, execute the following steps.

# sudo apt-get install software-properties-common python-software-properties
# sudo add-apt-repository ppa:ondrej/php
# sudo apt update
# sudo apt install -y php7.2

Install Required PHP Extensions

DokuWiki requires the following PHP extensions:

  1. php7.2-cli
  2. php7.2-fpm
  3. php7.2-gd
  4. php7.2-zip
  5. php7.2-xml
# sudo apt install -y php7.2-cli php7.2-fpm php7.2-xml php7.2-gd php7.2-zip
# php --version

Install Nginx Server

Before starting installation of Nginx server, you will need to stop apache service. To do so, execute the command below.

# sudo systemctl stop apache2
# sudo apt-get install nginx
# sudo systemctl start nginx
# sudo nginx -v
# sudo nano /etc/nginx/sites-available/doku.conf
server {
listen 80;
listen [::]:80;
return 301 https://$server_name$request_uri;

server {
listen [::]:443 ssl;
listen 443 ssl;

ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

# Maximum file upload size is 4MB - change accordingly if needed
client_max_body_size 4M;
client_body_buffer_size 128k;

root /var/www/dokuwiki;
index doku.php index.html index.htm index.php;

#Remember to comment the below out when you're installing, and uncomment it when done.
location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; }
# Uncomment this prevents images being displayed !
# location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
# expires 31536000s;
# add_header Pragma "public";
# add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
# log_not_found off;
# }

location / { try_files $uri $uri/ @dokuwiki; }

location @dokuwiki {
# rewrites "doku.php/" out of the URLs if you set the userewrite setting to .htaccess in dokuwiki config page
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$ {
try_files $uri $uri/ /doku.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# sudo ln -s /etc/nginx/sites-available/doku.conf /etc/nginx/sites-enabled/
# sudo nginx -t
# sudo systemctl reload nginx

Install and Configure DokuWiki

To install and configure DokuWiki, follow the steps below.

# cd /var/www
# sudo wget
# sudo tar xvf dokuwiki-stable.tgz
# sudo mv /var/www/dokuwiki-2018-04-22a /var/www/dokuwiki
# cd dokuwiki
# sudo chown -R www-data:www-data /var/www/dokuwiki

Install SSL Certificate

You will use Let’s Encrypt Certbot to install free SSL certificate. Certbot team maintains a PPA for Let’s Encrypt.

# sudo apt-get update
# sudo apt-get install software-properties-common
# sudo add-apt-repository ppa:certbot/certbot
# sudo apt-get update
# sudo apt-get install python-certbot-nginx
# sudo certbot --nginx -d
# sudo systemctl restart php7.2-fpm.service
# sudo systemctl reload nginx

Remove install.php File

It is important to remove install.php file to avoid security related problems in future. To do so, follow the steps below.

# cd /var/www/dokuwiki
# ls -li
# sudo rm install.php
# ls -li



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: