(Last Updated On: March 16, 2019)

This guide will take you through the steps to install Wiki.js NodeJS Wiki Application on Ubuntu 18.04  and CentOS 7. Wiki.js is an open source, modern and powerful wiki app built on Node.js, Git, and Markdown. Wiki.js runs on Linux, macOS and Windows operating systems.

In Wiki.js, you write all content in the widely used and simple Markdown format, using the built-in visual editor. The content is directly saved into Markdown (.md) files and automatically synced with your remote Git repository. All your content is readable directly from your Git repository.

Features of Wiki.js

  • 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
  • It is free to use and open-source

Server Requirements

  • Node.js 6.9.0 or later
  •  MongoDB 3.2 or later
  • Git 2.7.4 or later
  • A Git-compliant repository (public or private) (optional)

Note that the version of git available on CentOS 7 repository is a bit old, install the latest version of git using the guide How to Install latest version of Git ( Git 2.x ) on CentOS 7

We’ll use Nginx to proxy Wiki.js access and pm2 to start the application on boot.

Step 1: Install Node.js 8.x and Nginx

On CentOS 7

curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum install -y nodejs nginx gcc-c++ make
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

For Ubuntu 18.04 / Ubuntu 16.04

curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt -y install nodejs

Step 2: Install MongoDB

Wiki.js stores administrative data such as users, permissions and assets metadata in a MongoDB database.

Article contents and uploads are not stored in the DB. Instead, they are stored on-disk and synced automatically with a remote git repository of your choice.

Use our guides to install MongoDB

How to Install MongoDB 4 on CentOS 7

How to install Latest MongoDB on Ubuntu 18.04 / Ubuntu 16.04

Step 3: Download and install Wiki.js

Create a project directory

mkdir /srv/wikijs

Switch to project directory

cd /srv/wikijs

Install Wikijs

VERSION=$(curl -L -s -S https://beta.requarks.io/api/version/stable)
curl -L -s -S https://github.com/Requarks/wiki/releases/download/v$VERSION/wiki-js.tar.gz | tar xz -C .
curl -L -s -S https://github.com/Requarks/wiki/releases/download/v$VERSION/node_modules.tar.gz | tar xz -C .

Create Wiki configuration file

cp -n config.sample.yml config.yml

To view installed version, use

# node wiki --version

Step 4: Configure Wiki.js

Start the configuration wizard by running the command:

node wiki configure

To use a custom port, use the following command:

node wiki configure 1234

Where 1234 is the custom port. As an example, I’ll configure Wiki.js to use port 8080 on my server

node wiki configure 8080

Leave this terminal active and open a new terminal session to configure nginx

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

For http connection without ssl, add:

# Wikijs Nginx configuration file
server {
    listen      80;
    server_name wiki.example.com;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        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;

The following configuration snippet is for http and https, but with a redirect from http to https.

# Redirect http to https
server {
    listen      80;
    server_name wiki.example.com;
    return      301 https://$server_name$request_uri;

# Serve https traffic

server {
    listen 443 ssl http2;
    server_name  wiki.example.com;

    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/wiki.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/wiki.example.com/privkey.pem;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        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;

Restart nginx service and ensure it is set to start on boot

sudo systemctl restart nginx
sudo systemctl enable nginx

Now open the link http://wiki.example.com/ and follow the installation wizard:

Ensure that dependency checks return a success

Set site title

Set MongoDB database connection

If your MongoDB is installed on the same host as Wiki.js, use:

Connection String: mongodb://localhost:27017/wiki

After a successful installation, you should get a ready to get started page.

Login to Wiki.js dashboard to start adding content

To stop Wiki.js, run the command:

node wiki stop

Restart Wiki.js

To restart Wiki.js, run the command:

node wiki restart

All settings entered during the configuration wizard are saved in the file config.yml

Step 5: Configure Wiki.js to start on boot

By default, Wiki.js will not start automatically following a system reboot. In order to make it start on boot, we need to setup pm2 as a global npm module and set it as a startup service:

PM2 is a Production Process Manager for Node.js applications with a built-in Load Balancer.

npm install -g pm2

We now need to tell pm2 to configure itself as a startup service.

pm2 startup

Finally, save the current pm2 configuration by running the command:

pm2 save

To remove init script via:

pm2 unstartup systemd

Thank you for using our guide to install Wiki.js on Ubuntu 18.04 / CentOS 7. See below other Wiki guides.

How to Install DokuWiki on Ubuntu 18.04 with Nginx and Letsencrypt

Install Dokuwiki with Nginx and Letsencrypt SSL on CentOS 7

How to Install Gollum Wiki on Ubuntu 18.04 LTS