How to Install Wiki.js on CentOS 8

how to install wiki.js on centos 8
how to install wiki.js on centos 8 easy guide

Wiki.js is a free and open-source wiki application written in Node.js. It is simple, lightweight, and uses Markdown files to saves all contents. You can save your content directly to the Markdown file and sync it with your Git repository. It offers a rich set of features including, integrated access control, a built-in search engine, and supports external authentication.

In this tutorial, we will show you how to install Wiki.js on CentOS 8.

Prerequisites

  1. A CentOS 8 VPS.
  2. Access to the root user account (or access to an admin account with root privileges)

Step 1: Log in to the Server & Update the Server OS Packages

First, log in to your CentOS 8 server via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address‘ and ‘Port_number‘ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.

Before starting, you have to make sure that all CentOS packages installed on the server are up to date. You can do this by running the following commands:

dnf update -y

Step 2: Install Node.js and Redis

Wiki.js is built on Node.js. So you will need to install Node.js in your system. First, install all required dependencies with the following command:

dnf install epel-release git curl unzip -y

Once all the dependencies are installed, add the Node.js repository with the following command:

curl -sL https://rpm.nodesource.com/setup_12.x | bash -

Next, install Node.js and Redis with the following command:

dnf install nodejs -y
dnf install redis -y

After installing both packages, start the Redis service and enable it to start at system reboot with the following command:

systemctl start redis
systemctl enable redis

Step 3: Install Nginx and MariaDB

Next, will need to install the Nginx web server and MariaDB database server to your system. You can install both packages with the following command:

dnf install nginx @mariadb -y

Once both packages are installed, start the Nginx and MariaDB service and enable them to start at system reboot with the following command:

systemctl start nginx
systemctl start mariadb
systemctl enable nginx
systemctl enable mariadb

Once installed, secure the MariaDB installation by running the following command:

mysql_secure_installation

Answer all the questions as shown below to set the MariaDB root password and secure the installation:

Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once the MariaDB is secured, log in to the MariaDB console with the following command:

mysql -u root -p

Once login, create a database and user for Wiki.js with the following command:

MariaDB [(none)]> CREATE DATABASE wikidb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wikidb.* TO 'wiki'@'localhost' IDENTIFIED BY 'password';

Next, flush the privileges and exit from the MariaDB with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Once the MariaDB is configured, you can proceed to install Wiki.js.

Step 4: Install Wiki.js

First, create a separate user and group for Wiki.js with the following command:

groupadd --system wiki
useradd -s /sbin/nologin --system -g wiki wiki

Next, download the latest version of Wiki.js with the following command:

curl -s https://api.github.com/repos/Requarks/wiki/releases/latest | grep browser_download_url  | grep -v windows | cut -d '"' -f 4 | wget -qi -

Next, create a directory for Wiki.js and extract the downloaded file to the /var/www/html/wiki directory:

mkdir -p /var/www/html/wiki
tar zxf wiki-js.tar.gz -C /var/www/html/wiki

Next, change the directory to the wiki and copy the sample configuration file:

cd /var/www/html/wiki
cp config.sample.yml config.yml

Next, edit the config.yml file and define your MariaDB database:

nano config.yml

Define your MariaDB database details as shown below:

db:
  type: mariadb

  # PostgreSQL / MySQL / MariaDB / MS SQL Server only:
  host: localhost
  port: 3306
  user: wiki
  pass: password
  db: wikidb
  ssl: false

Save and close the file then change the ownership of the wiki directory with the following command:

chown -R wiki:wiki /var/www/html/wiki

Next, verify the Wiki.js with the following command:

node server

If everything is fine, you should get the following output:

Loading configuration from /var/www/html/wiki/config.yml... OK
2020-11-09T08:16:24.205Z [MASTER] info: =======================================
2020-11-09T08:16:24.207Z [MASTER] info: = Wiki.js 2.5.170 =====================
2020-11-09T08:16:24.207Z [MASTER] info: =======================================
2020-11-09T08:16:24.207Z [MASTER] info: Initializing...
2020-11-09T08:16:24.801Z [MASTER] info: Using database driver mysql2 for mariadb [ OK ]
2020-11-09T08:16:24.805Z [MASTER] info: Connecting to database...
2020-11-09T08:16:24.834Z [MASTER] info: Database Connection Successful [ OK ]
2020-11-09T08:16:27.571Z [MASTER] warn: DB Configuration is empty or incomplete. Switching to Setup mode...
2020-11-09T08:16:27.572Z [MASTER] info: Starting setup wizard...
2020-11-09T08:16:27.747Z [MASTER] info: Starting HTTP server on port 3000...
2020-11-09T08:16:27.747Z [MASTER] info: HTTP Server on port: [ 3000 ]
2020-11-09T08:16:27.751Z [MASTER] info: HTTP Server: [ RUNNING ]
2020-11-09T08:16:27.751Z [MASTER] info: 
2020-11-09T08:16:27.751Z [MASTER] info: 
2020-11-09T08:16:27.751Z [MASTER] info: Browse to http://YOUR-SERVER-IP:3000/ to complete setup!
2020-11-09T08:16:27.751Z [MASTER] info: 
2020-11-09T08:16:27.751Z [MASTER] info: 

Step 5: Create a Systemd Service File for Wiki.js

Next, you will need to create a systemd service file to manage the Wiki.js service. You can create it with the following command:

nano /etc/systemd/system/wiki.service

Add the following lines:

[Unit]
 Description=Wiki.js
 After=network.target
 [Service]
 Type=simple
 ExecStart=/usr/bin/node server
 Restart=always
 User=wiki
 Environment=NODE_ENV=production
 WorkingDirectory=/var/www/html/wiki
 [Install]
 WantedBy=multi-user.target

Save and close the file then reload the systemd daemon with the following command:

systemctl daemon-reload

Next, start the wiki service and enable it to start at system reboot with the following command:

systemctl start wiki
systemctl enable wiki

Step 6: Configure Nginx as a Reverse Proxy

Next, you will need to configure Nginx as a reverse proxy to access the Wiki.js on port 80. First, create an Nginx virtual host configuration file with the following command:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
nano /etc/nginx/conf.d/wikijs.conf

Add the following lines:

server {
     listen      80;
     server_name wiki.example.com;
 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; 

 }
}

Save and close the file then restart Nginx service to apply the changes:

systemctl restart nginx

Step 7: Access Wiki.js

Now, open your web browser and access the Wiki.js using the URL http://wiki.example.com. You will be redirected to the following page:

 

how to install wiki.js on centos 8

Provide your admin email, password, site URL and click on the INSTALL button. You will be redirected to the Wiki.js login screen:

steps-on-how-to-install-wiki.js-on-centos-8

Provide your admin email, password and click on the Log In button. You should see the Wiki.js dashboard in the following screen:

easy guide on how to install wiki.js on centos 8
how-to-install-wiki.js-on-centos-8-easy-guide

Of course, you don’t have to install Wiki.js on CentOS 8, if you use one of our Managed CentOS Hosting plans, in which case you can simply ask our expert Linux admins to install Wiki.js on CentOS 8 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install Wiki.js on CentOS 8, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment