×
Community Blog How to Install and Configure Wiki.js on Alibaba Cloud ECS

How to Install and Configure Wiki.js on Alibaba Cloud ECS

In this tutorial, we will install and configure Wiki.js on Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04.

By Arslan Ud Din Shafiq, Alibaba Cloud Community Blog author.

Built on Git, Node.js, and Markdown, Wiki.js is an open-source powerful wiki application that allows you to easily write and manage your content in Markdown format. It uses caching to serve content to its users immediately and allows you to insert images, documents, schemas, links, and videos. Wiki.js provides you a built-in search engine to quickly find your wiki entry and also offers suggestions during the search.

In this tutorial, we will install and set up a Wiki.js on Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04 installed.

Prerequisites

  • 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 $300 – $1200 worth in Alibaba Cloud credits for your new account. If you don't know 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).
  • 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.
  • Domain name must be pointed to your Alibaba Cloud ECS's IP address
  • Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  • Set up your server's hostname and create a user with root privileges.

Setting Up Your Server

Before proceeding with the 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.

sudo apt update && sudo apt upgrade

Install Build-essential

Also, you need to install build-essential by running the command below.

sudo apt-get install build-essential -y

Install Apt-Transport-HTTPS

Install Apt-Transport-HTTPS by executing the following command.

sudo apt-get install apt-transport-https -y

Install Software-properties-common

To install software-properties-common, execute the command below.

sudo apt-get install software-properties-common

Install Git

Follow the steps below to install the latest version of Git.

Step 1: Add the repository by executing the command below.

sudo add-apt-repository -y ppa:git-core/ppa

Step 2: Update the system to load the added repository by executing the command below.

sudo apt update

Step 3: Execute the following command to begin the installation.

sudo apt install git -y

Step 4: To verify the installation of Git, execute the following command and check the current version of Git.

git --version

Install Node.js

Next, we need Node.js for the purpose of this tutorial. To install Node.js execute the steps listed below.

Step 1: Download the setup files by using the following command.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

Step 2: Now, install Node.js by executing command below.

sudo apt install -y nodejs

Install MongoDB

For Wiki.js, it is imperative to install MongoDB. In this tutorial, we will install the MongoDB community edition by executing the following command.

sudo apt install -y mongodb

To confirm whether the installation of MongoDB is correctly executed, check the installed version of MongoDB by executing the following command.

mongo --version | head -n 1 && mongod --version | head -n 1

Install Nginx Server

Nginx server is required to set up the reverse proxy and SSL certificate. Follow the steps listed below to install Nginx.

Step 1: Get the Nginx signing key by executing the command below.

wget https://nginx.org/keys/nginx_signing.key

Step 2: Add the downloaded Nginx signing key using the following command.

sudo apt-key add nginx_signing.key

Step 3: Add the repository to sources.list by executing the command below.

sudo -s

printf "deb https://nginx.org/packages/mainline/ubuntu/ $(lsb_release -sc) nginx\ndeb-src https://nginx.org/packages/mainline/ubuntu/ $(lsb_release -sc) nginx\n" >> /etc/apt/sources.list.d/nginx_mainline.list

exit

Step 4: Now, update your system by running the following command.

sudo apt update

Step 5: Execute the command below to start the installation of Nginx.

sudo apt install nginx -y

Step 6: To check whether the installation is correctly implemented, execute the following command and confirm the Nginx version.

sudo nginx -v

Step 7: Now, enable Nginx to ensure that it starts automatically when the system reboots.

sudo systemctl enable nginx.service

Step 8: Now, execute the following command to start Nginx server.

sudo systemctl start nginx.service

Setup Reverse Proxy

Wiki.js works on port 3000. Hence, you need to set up a reverse proxy. To implement this, create an Nginx configuration file for Wiki.js by using the following command.

sudo nano /etc/nginx/conf.d/wiki.conf

A text file will open. Copy and paste the below text in the file and save it.

server {

    listen [::]:80;
    listen 80;

    server_name softpedia.xyz;

    root /usr/share/nginx/html;

    charset utf-8;
    client_max_body_size 50M;

    location /.well-known/acme-challenge/ {
        allow all;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_next_upstream error timeout http_502 http_503 http_504;
    }
}

Remember to change softpedia.xyz with your domain name or IP address. Execute the following command to check whether the syntax is correct and the Nginx configuration file is right.

sudo nginx -t

Now, reload the Nginx server to load the newly saved configured file by executing the command below.

sudo systemctl reload nginx.service

Install Wiki.js

Follow the steps listed below to install Wiki.js.

Step 1: Navigate to /var/www/html using the command below. If the following command results in any error, you must be missing /var/www/html folder. You can rectify it by creating a www and html folder.

cd /var/www/html

Step 2: Now, change ownership of /var/www/html directory as shown below.

sudo chown -R aareez:aareez /var/www/html

Step 3: Remove index.html file using the command below.

sudo rm index.html

Also, download the latest stable release of Wiki.js using the command below.

curl -sSo- https://wiki.js.org/install.sh | bash

Step 4: To configure Wiki.js, execute the command below.

node wiki configure

As reverse proxy is already set up, there is no need to concatenate port 3000 at the end of the URL. You can simply access the configuration page from your browser by accessing your domain or IP address to navigate to the following page.

1

Click the Start button, to check if the system meets the requirements or not. You will be redirected to the following screen.

2

Click the Continue button to resume the configuration process. Once, you are redirected to the following page, add your site title, hostname, and default port on which you want to access the same. Next, select your desired language and give it public access if you want it to be accessed without a login. If you plan to use SSL, remember to use HTTPS in host instead of HTTP.

3

Once you click Continue, you will be redirected to the following screen.

4

On the following screen, you need to select the database and click Connect to continue.

5

Next, you will see the screen indicating Connected successfully! status. Click the Continue button to move to the next step.

Now, set up paths for data and local repository and click Continue.

6

If you have any Git repository, you can set it up in the following section otherwise you can skip this step.

7

Now, you need to set up an Admin account to access the Admin panel by filling in the following form.

8

Once the configuration is completed, you will see the following screen. Click the Start button to start Wiki.js.

9

Set Up Firewalls and Ports

If you have activated firewalls, you need to define a rule in Alibaba Cloud security group for your cloud server to add an exception for port 80/TCP, 443/TCP, and 3000/TCP. You can enable these ports while creating ECS instance, but in case if you have forgotten to unblock these ports, you can follow the procedure in this guide: https://www.alibabacloud.com/help/doc-detail/25471.htm

Install SSL Certificate

You need to use Certbot for installing the SSL certificate using Let's Encrypt. To do so, execute the following steps.

Step 1: Update the package using the following command

sudo apt-get update

Step 2: Install software-properties-common by executing the command below.

sudo apt-get install software-properties-common

Step 3: Add the Certbot repository by using the following command.

sudo add-apt-repository ppa:certbot/certbot

Step 4: Use the command below to update the package for loading the added Certbot repository.

sudo apt-get update

Step 5: Now, install python-certbot-nginx using the command below.

sudo apt-get install python-certbot-nginx

Step 6: Execute the following command to get Let's Encrypt SSL issued.

sudo certbot --nginx -d softpedia.xyz

Select Option 2 to redirect the link to https and update virtual host settings for SSL.

10

After a successful issuance of the SSL certificate, you will be navigated to the following screen.

11

Now, run the following command to restart the Nginx server.

sudo systemctl restart nginx

Now you can access your Wiki.js by hitting your URL.

There you go! You have successfully installed and configured Wiki.js on your server.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 764 followers

You may also like

Comments