You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

This guide will discuss the ideal steps for installing Wiki.js on CentOS 8 Linux machine. Wiki.js is an modern open source wiki application built on Node.js, Git, and Markdown. Wiki.js can be installed on Linux, macOS and Windows machines. With Wiki.js, you can write all documentation and web content in the widely used and simple Markdown format, using the built-in visual editor.

The content you write is directly saved into Markdown (.md) files and automatically synced with your remote Git repository. You can read all the content from your Git repository. Below you’ll find the key features of Wiki.js.

Key Features of Wiki.js

  • It is free to use and open-source
  • Beautifully designed for the modern web
  • Edit content in simple Markdown format
  • Has Integrated Access Control – Local database or external authentication providers like Microsoft Account, Google ID, Facebook, GitHub, Slack or LDAP (Active Directory).
  • Has Intuitive Assets Management
  • Lightweight and extremely powerful
  • Wiki.js has a built-in search engine

System setup requirements

  • Node.js 10.x or later
  • Redis cache
  • Git 2.x or later
  • A Git-compliant repository (public or private) (optional)

Install and Configure Wiki.js on CentOS 8

The next sections will focus on the installation of Wiki.js on CentOS 8 Linux machine. We’ll begin with the installation of required dependencies, then proceed to install and configure Wiki.js on CentOS 8.

Step 1: Update system and set timezone

Start by updating the system and setting correct timezone.

sudo yum -y update
sudo timedatectl list-timezones
sudo timedatectl set-timezone 'Africa/Nairobi' 

Step 2: Creating a dedicated user for Wiki.js

We’ll need a dedicated system user for running Wiki.js application. Let’s first create this user.

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

Step 3: Install basic dependency packages

Let’s also install all the dependency applications required for running Wiki.js on CentOS 8.

  • Install git, unzip and epel-release
sudo yum install -y epel-release git vim wget curl unzip socat
  • Install Node.js
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo yum install -y nodejs nginx
  • Install MariaDB database server
sudo yum -y install @mariadb
sudo systemctl enable --now mariadb
sudo mysql_secure_installation

Create database user and db.

$ mysql -u root -p

CREATE DATABASE wiki;
GRANT ALL PRIVILEGES ON wiki.* TO 'wikijs'@'localhost' IDENTIFIED BY '[email protected]';
FLUSH PRIVILEGES;
QUIT;
  • Install Redis
sudo yum -y install redis
sudo systemctl enable --now redis

Confirm all services status

$ systemctl status redis
● redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis.service.d
           └─limit.conf
   Active: active (running) since Tue 2019-12-10 18:27:35 EAT; 20s ago
 Main PID: 661 (redis-server)
    Tasks: 4 (limit: 11512)
   Memory: 6.5M
   CGroup: /system.slice/redis.service
           └─661 /usr/bin/redis-server 127.0.0.1:6379

Dec 10 18:27:35 centos8.novalocal systemd[1]: Starting Redis persistent key-value database...
Dec 10 18:27:35 centos8.novalocal systemd[1]: Started Redis persistent key-value database.

$ systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-12-08 10:50:05 EAT; 2 days ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 2581 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 11512)
   Memory: 78.0M
   CGroup: /system.slice/mariadb.service
           └─2581 /usr/libexec/mysqld --basedir=/usr

Dec 08 10:50:05 centos8.novalocal mysql-prepare-db-dir[2479]: Please report any problems at http://mariadb.org/jira
Dec 08 10:50:05 centos8.novalocal mysql-prepare-db-dir[2479]: The latest information about MariaDB is available at http://mariadb.org/.
Dec 08 10:50:05 centos8.novalocal mysql-prepare-db-dir[2479]: You can find additional information about the MySQL part at:
Dec 08 10:50:05 centos8.novalocal mysql-prepare-db-dir[2479]: http://dev.mysql.com
Dec 08 10:50:05 centos8.novalocal mysql-prepare-db-dir[2479]: Consider joining MariaDB's strong and vibrant community:
Dec 08 10:50:05 centos8.novalocal mysql-prepare-db-dir[2479]: https://mariadb.org/get-involved/
....

Step 4: Download Wiki.js

Download the latest release of Wiki.js

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

Extract the package to the final destination of your choice

sudo mkdir /srv/wiki
sudo tar zxf wiki-js.tar.gz -C /srv/wiki

Create configuration file from provided template.

cd /srv/wiki
sudo cp config.sample.yml config.yml

Modify the config file and fill in your database, redis and port settings:

$ vim config.yml

#######################################################################
# Wiki.js - CONFIGURATION                                             #
#######################################################################
# Full documentation + examples:
# https://docs.requarks.io/install

# ---------------------------------------------------------------------
# Port the server should listen to
# ---------------------------------------------------------------------

port: 3000

# ---------------------------------------------------------------------
# Database
# ---------------------------------------------------------------------
# Supported Database Engines:
# - postgres = PostgreSQL 9.5 or later
# - mysql = MySQL 8.0 or later (5.7.8 partially supported, refer to docs)
# - mariadb = MariaDB 10.2.7 or later
# - mssql = MS SQL Server 2012 or later
# - sqlite = SQLite 3.9 or later

db:
  type: mariadb
  # PostgreSQL / MySQL / MariaDB / MS SQL Server only:
  host: localhost
  port: 3306
  user: wikijs
  pass: '[email protected]'
  db: wiki
  ssl: false
  # SQLite only:
  storage: path/to/database.sqlite

#######################################################################
# ADVANCED OPTIONS                                                    #
#######################################################################
# Do not change unless you know what you are doing!

# ---------------------------------------------------------------------
# SSL/TLS Settings
# ---------------------------------------------------------------------
# Consider using a reverse proxy (e.g. nginx) if you require more
# advanced options than those provided below.

ssl:
  enabled: false

  # Certificate format, either 'pem' or 'pfx':
  format: pem
  # Using PEM format:
  key: path/to/key.pem
  cert: path/to/cert.pem
  # Using PFX format:
  pfx: path/to/cert.pfx
  # Passphrase when using encrypted PEM / PFX keys (default: null):
  passphrase: null
  # Diffie Hellman parameters, with key length being greater or equal
  # to 1024 bits (default: null):
  dhparam: null

  # Listen on this HTTP port and redirect all requests to HTTPS.
  # Set to false to disable (default: 80):
  redirectNonSSLPort: 80

# ---------------------------------------------------------------------
# Database Pool Options
# ---------------------------------------------------------------------
# Refer to https://github.com/vincit/tarn.js for all possible options

pool:
  # min: 2
  # max: 10

# ---------------------------------------------------------------------
# IP address the server should listen to
# ---------------------------------------------------------------------
# Leave 0.0.0.0 for all interfaces

bindIP: 0.0.0.0

# ---------------------------------------------------------------------
# Log Level
# ---------------------------------------------------------------------
# Possible values: error, warn, info (default), verbose, debug, silly

logLevel: info

# ---------------------------------------------------------------------
# Upload Limits
# ---------------------------------------------------------------------
# If you're using a reverse-proxy in front of Wiki.js, you must also
# change your proxy upload limits!

uploads:
  # Maximum upload size in bytes per file (default: 5242880 (5 MB))
  maxFileSize: 5242880
  # Maximum file uploads per request (default: 20)
  maxFiles: 10

# ---------------------------------------------------------------------
# Offline Mode
# ---------------------------------------------------------------------
# If your server cannot access the internet. Set to true and manually
# download the offline files for sideloading.

offline: false

# ---------------------------------------------------------------------
# Data Path
# ---------------------------------------------------------------------
# Writeable data path for Wiki.js, mainly for cache and user uploads.
dataPath: ./data

Test your configurations by running Wiki.js:

sudo node server

You should get output similar to below.

Step 4: Configure Wiki.js service

Now configure Wiki.js application to run as a service.

sudo vim /etc/systemd/system/wiki.service

Add:

[Unit]
Description=Wiki.js
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/node server
Restart=always
User=wiki
Environment=NODE_ENV=production
WorkingDirectory=/srv/wiki

[Install]
WantedBy=multi-user.target

Give user permissions for the directory.

sudo chown -R wiki:wiki /srv/wiki

Reload systemd and start service.

sudo systemctl daemon-reload
sudo systemctl enable --now wiki.service

Confirm service status

$ systemctl status wiki

You should get an output similar to below.

The service should bind to TCP port 3000:

$ ss -tunelp | grep 3000
tcp   LISTEN  0       128                  0.0.0.0:3000           0.0.0.0:*      uid:977 ino:283510 sk:e <->  

Install and configure Nginx reverse proxy

Install and start Nginx web service.

sudo yum -y install nginx
sudo systemctl enable --now nginx

If you have firewalld service running, allow the service.

sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

Configure SELinux:

sudo semanage port -a -t http_port_t -p tcp 3000
sudo setsebool -P httpd_can_network_connect 1

Create Nginx configuration file for Wiki.js

$ sudo vim /etc/nginx/conf.d/wikijs.conf

Modify and paste below data

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;
    }
}

Confirm nginx configuration and restart service.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

$ sudo systemctl restart nginx

Open the URL on the web browser to finish Wiki.js installation on CentOS 8.

Fill required admin details then click “Install” button.

Wait for the installation to finish.

Use the credentials provided during installation to login.

Agree to create home page in the first screen.

Visit the official Wiki.js documentation to learn how to configure Wiki and add pages.

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF