Skip to main content

Wiki.js Setup

Antoine de Barbarin

Installation

Download the latest version of Wiki.js:

wget https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz

Extract the package to a new folder /srv/wikijs:

mkdir /srv/wikijs
tar xzf wiki-js.tar.gz -C /srv/wikijs
cd /srv/wikijs

Rename the sample config file to config.yml:

mv config.sample.yml config.yml

Edit the config file and fill in your database and port settings (host: 172.17.0.6, port: 5432, user: wikijs, database: wikijs) and set hato true:

vim config.yml

On the PostgreSQL Server, give access to the user wikijs on the database wikijs from both web servers. Add the following text in the file /var/lib/pgsql/17/data/pg_hba.conf

host    wikijs          wikijs          172.16.0.2/32            scram-sha-256
host    wikijs          wikijs          172.16.0.3/32            scram-sha-256

Back to our webserver, run Wiki.js with the command

node server

image-20250601121248319

Open the browser with the URL http://172.16.0.2:3000/ and fill the form

image-20250601121540857

When the installation is complete, you will be redirected to the login page. The setup is complete, you can log in with the administrator account.

image-20250601122843218

image-20250601122914711

Run as service

Create a new system user to run wikijs and give complete ownership of /srv/wikijs to it

useradd -r wikijs -s /bin/false -d /srv/wikijs
chown -R wikijs:wikijs /srv/wikijs

Running the command cat /etc/passwd | grep wikijs, you should see something similar

wikijs:x:998:995::/srv/wikijs:/bin/false

And running ll /srv & ll /srv/wikijs, you should also see

total 4
drwxr-xr-x 6 wikijs wikijs 4096 Jun  1 09:56 wikijs
total 104
drwxr-xr-x   8 wikijs wikijs  4096 Mar 24 01:36 assets
-rw-r--r--   1 wikijs wikijs  4974 Jun  1 09:56 config.yml
drwxr-xr-x   5 wikijs wikijs  4096 Jun  1 10:26 data
-rw-r--r--   1 wikijs wikijs 34520 Mar 24 01:33 LICENSE
drwxr-xr-x 953 wikijs wikijs 36864 Mar 24 01:37 node_modules
-rw-r--r--   1 wikijs wikijs 12267 Mar 24 01:33 package.json
drwxr-xr-x  17 wikijs wikijs  4096 Mar 24 01:33 server

Create a new file named wikijs.service inside directory /etc/systemd/system.

vim /etc/systemd/system/wikijs.service

Paste the following contents (assuming your wiki is installed at /var/wiki):

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

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

[Install]
WantedBy=multi-user.target

Reload systemd:

systemctl daemon-reload

Run the service:

systemctl start wikijs

Enable the service on system boot.

systemctl enable wikijs