Wiki.js is a robust open-source wiki app built on Node.js, Git, and Markdown. It efficiently utilizes resources due to its reliance on the fast Node.js engine. Some key features of Wiki.js include:
- Markdown editing with Git backing
- A lightweight yet powerful platform
- Sleek design tailored for the modern web
- Integrated access control
- Intuitive asset management
- A built-in search engine
This guide will lead you through the process of installing Wiki.js version 1 on Debian 9, employing NGINX as a reverse proxy, MongoDB as your database, PM2 for process management, and optionally securing your setup with Let’s Encrypt.
Requirements
Ensure you have the following to run Wiki.js:
- Node.js version 6.11.1 to 10.x
- MongoDB version 3.2 or later
- Git version 2.7.4 or later
- Web Server software such as NGINX, Apache, Caddy, H2O…
- An optional empty Git repository
- At least 512MB RAM (1GB recommended)
- Approximately 300MB of disk space
- A domain with A/AAAA DNS records configured
Prerequisites
- Debian 9 operating system
- A non-root user with
sudo
privileges
Initial Steps
Verify your Debian version:
lsb_release -ds
# Debian GNU/Linux 9.8 (stretch)
Set the timezone:
dpkg-reconfigure tzdata
Update your system packages:
apt update && apt upgrade -y
Install essential packages for basic management:
apt install -y curl wget vim git unzip socat sudo bash-completion apt-transport-https build-essential dirmngr
Step 1 – Install Node.js and npm
Wiki.js is built on Node.js. We will install the latest recommended version (v10 at the time of writing):
Download and install Node.js:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejs
Check Node.js and npm version:
node -v && npm -v
# v10.15.1
# 6.4.1
Update npm to the latest version:
sudo npm install -g npm@latest
Step 2 – Install MongoDB
Wiki.js supports MongoDB as its database engine. Install MongoDB:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
Start and enable MongoDB service:
sudo systemctl start mongod.service
sudo systemctl enable mongod.service
Step 3 – Obtain SSL Certificate with acme.sh (Optional)
Use acme.sh to obtain a Let’s Encrypt certificate for HTTPS:
Download and install acme.sh:
sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail your_email@example.com
source ~/.bashrc
cd ~
Obtain SSL certificates:
# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256
Install certificates:
# RSA
acme.sh --install-cert -d example.com \
--cert-file /etc/letsencrypt/example.com/cert.pem \
--key-file /etc/letsencrypt/example.com/private.key \
--fullchain-file /etc/letsencrypt/example.com/fullchain.pem \
--reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA acme.sh --install-cert -d example.com --ecc \ --cert-file /etc/letsencrypt/example.com_ecc/cert.pem \ --key-file /etc/letsencrypt/example.com_ecc/private.key \ --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem \ --reloadcmd "sudo systemctl reload nginx.service"
Step 4 – Install and Configure NGINX
NGINX will serve as a reverse proxy for Wiki.js. Install NGINX:
wget https://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
rm nginx_signing.key
sudo -s
printf "deb https://nginx.org/packages/mainline/debian/ $(lsb_release -sc) nginx\ndeb-src https://nginx.org/packages/mainline/debian/ $(lsb_release -sc) nginx\n" >> /etc/apt/sources.list.d/nginx_mainline.list
exit
sudo apt update
sudo apt install -y nginx
Configure NGINX:
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:80;
listen 80;
server_name example.com;
charset utf-8;
client_max_body_size 50M;
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
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;
}
}
Reload NGINX for changes to take effect:
sudo systemctl reload nginx.service
Step 5 – Install and Setup Wiki.js
Create a document root directory for Wiki.js:
sudo mkdir -p /var/www/wiki.js
Navigate to the directory:
cd /var/www/wiki.js
Change the directory ownership:
sudo chown -R [your_user]:[your_user] /var/www/wiki.js
Install the latest Wiki.js:
curl -sSo- https://wiki.js.org/install.sh | bash
Run the configuration wizard:
node wiki configure
Use your browser to complete the setup at http://example.com
.
Step 6 – Setup PM2 Process Manager
Configure PM2 to manage Wiki.js:
/var/www/wiki.js/node_modules/pm2/bin/pm2 startup
/var/www/wiki.js/node_modules/pm2/bin/pm2 save
Links
FAQ
What is Wiki.js?
Wiki.js is an open-source wiki application designed for easy deployment and management, utilizing Node.js for high performance and efficiency.
Which database does Wiki.js require?
Wiki.js supports MongoDB as its database engine, version 3.2 or later is required.
Can I use a web server other than NGINX?
Yes, you can use web servers such as Apache, Caddy, or others. Configuration though may vary.
Do I need to set up HTTPS?
While it’s optional, securing your site with HTTPS is recommended for safe data transmission. This guide includes an optional setup for Let’s Encrypt SSL certificates.