×
Community Blog Install and Configure DokuWiki on Alibaba Cloud ECS

Install and Configure DokuWiki on Alibaba Cloud ECS

In this tutorial, we will be installing and setting up DokuWiki on Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04 installed.

By Arslan Ud Din Shafiq, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

DokuWiki is an open source wiki software that lets you build a collaborative app easily. DokuWiki is popular due to its readable syntax, and is also liked by website administrators because it is easy to maintain, manage, backup and integrate.

In this tutorial, we will be installing and setting up DokuWiki using Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04 installed.

In this tutorial, I will be using Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04 installed on it.

Prerequisites

  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.

Step 1:

# 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.

Install python software properties and software properties common. To do so, execute the command below.

# sudo apt-get install software-properties-common python-software-properties 

You will need to add repository for newer versions of PHP. To do so, execute the commands below.

# sudo add-apt-repository ppa:ondrej/php

Update the package to refresh the available repositories. To do so, execute the command for updating Ubuntu system.

# sudo apt update

Install PHP 7.2. To install PHP 7.2, execute the following command.

# 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

To install the above extensions of PHP, execute the following command.

# sudo apt install -y php7.2-cli php7.2-fpm php7.2-xml php7.2-gd php7.2-zip

To check PHP installation, you can execute the following command to check installed PHP version.

# 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

Execute the command below to install Nginx server.

# sudo apt-get install nginx

Now start Nginx server by executing command below.

# sudo systemctl start nginx

To check installation of Nginx server, you can execute the following command.

# sudo nginx -v

Create Nginx configuration file for DokuWiki. Execute the following command, a file will be opened in nano text editor.

# sudo nano /etc/nginx/sites-available/doku.conf

Copy and paste the following code and save the file.

server {
    listen               80;
    listen                   [::]:80;
    server_name          softpedia.xyz;
    return 301 https://$server_name$request_uri;
}
 
server {
    listen [::]:443 ssl;
    listen 443 ssl;
    server_name softpedia.xyz;
 
    ssl_certificate /etc/letsencrypt/live/softpedia.xyz/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/softpedia.xyz/privkey.pem; # 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;
    }
}

Now create symlink of newly created file's configuration to enabled-sites directory. To do so, execute the command below.

# sudo ln -s /etc/nginx/sites-available/doku.conf /etc/nginx/sites-enabled/

Now execute the following command to test the syntax of Nginx configuration file.

# sudo nginx -t

Execute the following command to reload the updated configurations.

# sudo systemctl reload nginx

Install and Configure DokuWiki

To install and configure DokuWiki, follow the steps below.

Navigate to root document directory.

# cd /var/www

Now download the files of DokuWiki from the DokuWiki official website by executing commands below.

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

Extract the files from downloaded directory by executing command below.

# sudo tar xvf dokuwiki-stable.tgz

Now rename the extracted directory to dokuwiki using the command below.

# sudo mv /var/www/dokuwiki-2018-04-22a /var/www/dokuwiki

Navigate to /var/www/DokuWiki

# cd dokuwiki

Now change the ownership of newly created directory to your username.

# 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.

Update the package by executing command below.

# sudo apt-get update

Now you will need to install software-properties-common by executing command below.

# sudo apt-get install software-properties-common

Now add the certbot PPA to repository using the command below.

# sudo add-apt-repository ppa:certbot/certbot

Now update the package again by executing command below.

# sudo apt-get update

Install python-certbot-nginx by executing command below.

# sudo apt-get install python-certbot-nginx

To get Let's Encrypt SSL issued for your domain, execute the command below. Remember to change softpedia.xyz with your own domain name.

# sudo certbot --nginx -d softpedia.xyz

Restart php7.2-fpm service by executing the command below.

# sudo systemctl restart php7.2-fpm.service

Reload nginx server to load all settings.

# sudo systemctl reload nginx

Now you can access DokuWiki via ECS IP address or your domain name. In my case, I have setup domain. After accessing DokuWiki, you will be redirected to the following page.

1

You will have to make few changes to make DokuWiki work correctly. To do so, follow the steps below.

Navigate to link https://your_domain_name/install.php or http://your_ip_address/install.php

Remember, in case, you don't have any domain registered, you may buy it from Alibaba Cloud. Otherwise, you will have to skip SSL installation section to avoid errors. In case of using IP address of ECS, you will have to update nginx configuration in doku.conf file.

Select you desired language. DokuWiki supports more than 50 languages.

Fill the following form and save it.

2

You will see the following screen which shows the configuration was finished successfully.

3

To continue to your new DokuWiki, you are recommended to delete install.php file from your Alibaba Cloud ECS instance.

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.

Connect to your ECS shell via Putty or console and login.

Navigate to /var/www/dokuwiki using the command below.

# cd /var/www/dokuwiki

Execute the following command to see either you are in right folder or not.

# ls -li

4

Now execute the following command to remove install.php file.

# sudo rm install.php

To confirm that either the file has been deleted successfully or not, execute the command below.

# ls -li

You can see in the following screen, there is no file named install.php which means the file has been deleted successfully.

5

Now you can navigate to https://your_domain_name/doku.php?id=wiki:welcome , you will see the following screen.

6

That's it! Your DokuWiki is ready to use.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 764 followers

You may also like

Comments