19 C
Texas

How To Install wiki.js on CentOS 8

What is Wiki.js?

Wiki.js is a modern open source wiki application used to write all documentation & web content in the widely used and simple Markdown format using the built-in visual editor. It was built on Node.js, Git, and Markdown. Wiki.js allows the saving of your content directly into Markdown (.md) files & it synced with your remote Git repository.

Here are some salient features of wiki.js

Salient Features of Wiki.js

  • Easy & free to use
  • Open source product
  • Specially designed for the modern web
  • Add, edit or delete content in simple Markdown format
  • Integrated Access Control: Local db or external authentication providers like Microsoft Account, Google Account, Facebook, Github etc.
  • It is light & more powerful.
  • having built-in search engine.

Requirements:

  • Minimum Node.js 10.x
  • Redis cache
  • Minimimum Git 2.x
  • Git repo (public or private) (optional)

Installing Wiki.js on CentOS 8

Step 1: Updating your system

sudo yum -y update

Setting time zone.

- Advertisement -
sudo timedatectl list-timezones
sudo timedatectl set-timezone 'Asia/Karachi'

Step 2: Install Requirements

Install the required package for wiki.js

1.Installing git, unzip and epel-release

sudo yum install -y epel-release git vim wget curl unzip socat

2.Installing Node.js

curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo yum install -y nodejs nginx

3.Installing MariaDB server.

sudo yum -y install @mariadb
sudo systemctl enable --now mariadb
sudo mysql_secure_installation

After installation of MariaDB, create DB user and db.

$ mysql -u root -p
CREATE DATABASE wiki;
GRANT ALL PRIVILEGES ON wiki.* TO 'wikijs'@'localhost' IDENTIFIED BY 'Your_Password_Here';
FLUSH PRIVILEGES;
QUIT;

4.Installing Redis

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

Check that redis is working properly

[sabi@localhost ~]$ systemctl status redis
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor prese>
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: active (running) since Tue 2019-12-24 06:28:41 PKT; 13s ago
Main PID: 12599 (redis-server)
Tasks: 4 (limit: 4922)
Memory: 3.4M
CGroup: /system.slice/redis.service
└─12599 /usr/bin/redis-server 127.0.0.1:6379
Dec 24 06:28:41 localhost.localdomain systemd[1]: Starting Redis persistent key>
Dec 24 06:28:41 localhost.localdomain systemd[1]: Started Redis persistent key->
lines 1-13/13 (END)

Now, we move towards the installation of wiki.js on centos 8 by updating our system.

Step 3: Creat a dedicated user for Wiki.js

You will require a dedicated user for running wiki.js application.

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

Step 4: Download Wiki.js

You can download the latest release of Wiki.js from the Github release page.

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

After the download get completed, extract the packages to your desired location.

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

Now, create a configuration file from the provided template.

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

Edit the configuration file and provide the details about DB, redis and ports.

#
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: postgres
# PostgreSQL / MySQL / MariaDB / MS SQL Server only:
host: localhost
port: 5432
user: wikijs
pass: wikijsrocks
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
113,1 Bot

After finishing all these, its time to test the Wiki.js configuration

Type the below command to test configuration. You will see the output similar to the image below:

[sabi@localhost wiki]$ sudo node server
[sudo] password for sabi:
Loading configuration from /srv/wiki/config.yml… OK
2019-12-24T01:40:42.220Z [MASTER] info: =======================================
2019-12-24T01:40:42.223Z [MASTER] info: = Wiki.js 2.0.12 ======================
2019-12-24T01:40:42.223Z [MASTER] info: =======================================
2019-12-24T01:40:42.223Z [MASTER] info: Initializing…
2019-12-24T01:40:42.842Z [MASTER] info: Connecting to database…

Step 5: Configure Wiki.js service

Run the below command to run Wiki.js application as a service.

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

Paste the given data to the file.

[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

Allow user permission for the directory.

sudo chown -R wiki:wiki /srv/wiki

Reload & start services.

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

Make sure that status is working

systemctl status wiki

Bind the service 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 <->

Step 6: Install and Configure Nginx reverse proxy

Run the given command to install nginx services.

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

Allow firewall.

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 new configuration file for wiki.js

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

Now, add the below data into it.

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

Check the nginx configuration file and restart services.

$ 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

Now, open the URL on the web browser to finish Wiki.Js installation on CentOS 8.

Provide credential details and Click “Install” button.

It will finalize your Installation.

Provide the details to login.

Click on Create Home Page.

Congratulations! You have successfully installed wiki.js on your CentOS 8. Enjoy it!

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article