This guide covers the installation and configuration of Wiki.js on an Arch Linux server, using PostgreSQL as the database backend and Nginx as a reverse proxy. By the end, Wiki.js will be accessible securely over HTTPS.
#Server Requirements:
As always, update the system first!
$ pacman -S nodejs postgresql nginx certbot
Create a database, user and password for Wiki.js. The user must have access to the database. Follow instructions on how to use PostgreSQL here. Also make sure to start
and enable
PostgreSQL:
$ systemctl enable --now postgresql.service
As detailed on the official documentation: https://docs.requarks.io/install/linux
I will be making slight adjustments here and there.
I will be installing it into /srv/wikijs
, so lets create the directory, download the latest version of Wiki.js, extract it and remove the archive:
mkdir -p /srv/wikijs
wget https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz \
-O /srv/wikijs/wiki-js.tar.gz
tar xzf /srv/wikijs/wiki-js.tar.gz
rm /srv/wikijs/wiki-js.tar.gz
Wiki.js comes with an example configuration file named config.sample.yml
, lets use it and modify it slightly later. Wiki.js expects the configuration file to be placed in the servers root named config.yml
.
mv /srv/wikijs/config.sample.yml /srv/wikijs/config.yml
For the entire configuration refer to the original documentation
Technically, only a database connection and a port have to be defined in /srv/wikijs/config.yml
. However, it is a good idea to configure some other things as well.
The HTTP port will not really matter as I will be configuring Nginx later. It is still good to check and take note of the port. Default is 3000
and I will not be changing it.
port: 3000
I will be using PostgreSQL, which is recommended by Wiki.js. The PostgreSQL server will be running on the same server as Wiki.js is installed. The database is named wiki
and the user (role) wikijs
.
db:
type: postgres
host: localhost
port: 5432
user: wikijs
pass: PASSWORD
db: wiki
Note:
As the original documentation points out
It's not recommended to change these settings unless you know what you're doing.
So I will be using the defaults of:
pool:
min: 2
max: 10
More information can be found at tarn.js
This is the directory Wiki.js will be storing temporary data. By default it is ./data
. As Wiki.js is only storing temporary, I don't see the need to change it.
dataPath: /path/to/directory
Later, I will be creating a systemd service to run Wiki.js in the background as the http user. The user does not have to be http, but as far as I have noticed, http is the convention for serving websites on Arch Linux as opposed to www on Ubuntu for example.
This means the http user has to have read
and write
permission on the Wiki.js files:
$ chown -R http:http /srv/wikijs
Wiki.js can be started using
node server
in the direcotry it is installed to.
In order to run Wiki.js as a background service, I will be using systemd. Create and edit a service named /etc/systemd/service/wiki.service
.
[Unit]
Description=Wiki.js
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/node server
Restart=always
# Consider creating a dedicated user for Wiki.js here:
User=http
Environment=NODE_ENV=production
WorkingDirectory=/srv/wikijs
[Install]
WantedBy=multi-user.target
Note:
WorkingDirectory
is set to where Wiki.js is installed to: /srv/wikijs
User
is set to http
Don't forget to reload systemd!
$ systemctl daemon-reload
Now, the service can be started and enabled if it should start at boot.
$ systemctl enable --now wiki.service
Note:
journalctl -u wiki
At this point Wiki.js should be accessible at localhost:3000
, it will ask to complete a setup wizard creating an administrator account.
Refer to this guide on how to install and configure nginx.
Create a nginx server block, in my case /etc/nginx/sites-available/wiki.conf
.
server {
# Replace with domain
server_name DOMAIN;
listen 80;
access_log /var/log/nginx/wiki.access;
error_log /var/log/nginx/wiki.error;
# Adjust for larger uploads
client_max_body_size 10G;
client_body_timeout 36000s;
location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Replace with your IP or localhost
proxy_pass http://IPOFWIKIJS:3000;
}
}
Note:
server_name
expects a valid domain.proxy_pass
expects a valid IP address
or localhost
if nginx and Wiki.js are running on the same system.Create a symlink to enable the nginx server block:
ln -s /etc/nginx/sites-available/wiki.conf /etc/nginx/sites-enabled/wiki.conf
Test the nginx configuration file:
nginx -t
Restart nginx
$ systemctl restart nginx.service
Just run certbot and follow the instructions to obtain a SSL certificate from letsencrypt:
$ certbot --nginx
At this point Wiki.js should be accessible via HTTPS at the defined domain.