Getting Wiki With It

After trialling XWiki for quite some time, I finally came to the conclusion that it was just to "heavy" and complex for the work that I wanted it to be doing. I also found the extension system to be incredibly unfriendly and unclear at times. There was a mix of free and paid extensions together without any real separation. This isn't to say that it isn't a perfectly good platform. It's fantastic. To provide the service, I just needed something a little more lightweight, quicker and "prettier". I'm shallow that way.

I toyed with the idea of Wiki.js, finally deciding it was time to take the plunge. The XWiki had the content exported and the docker container shut down. I opted not to go the container route for this installation as I prefer to have control over what is happening. Besides, it just adds a layer of complexity that really isn't required.

The platform is an CentOS 7 VM hosted within vSphere with 4 GB RAM and plenty of CPU power to be thrown at it. The server requirements for Wiki.js are minimal, so this server has more than enough to play with. The remaining requirements were PostgreSQL & Node.js.

PostgreSQL

The installation process itself for PostgreSQL was pretty simple, following the docs on the site. Unfortunately I couldn't use the version included in the existing repo as it was too old and didn't meet the requirements.

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

yum install postgresql12-server

/usr/pgsql-12/bin/postgresql-12-setup initdb

systemctl enable postgresql-12systemctl start postgresql-12


Once that was done, I jumped in to the psql prompt and created the user, database and assigned ownership:

sudo -u postgres psql

CREATE DATABASE yourservice-wiki;

CREATE USER yourserviceuser-wiki WITH PASSWORD 'keepitsecret';

GRANT ALL PRIVILEGES ON DATABASE yourservice-wiki to yourserviceuser-wiki;

Node.js

Installing node is not something I've had to do for quite some time. It also didn't seem like an overly friendly experience either. There was a few different paths I could head down on this route but eventually opted for NVM (Node Version Manager) as I felt that this would offer me the control I wanted over which version to install.

Once that was installed it was a case of a couple of commands to pick up the version I wanted (12.x LTS).

nvm install v12.x.x

nvm use 12.x.x

Wiki.js Install

Finally, on to the meat of the whole thing. The "installation" of Wiki.js itself is truly trivial. The installation guide is here but I'll go through them below.

  1. Download the latest version of Wiki.js:
wget https://github.com/Requarks/wiki/releases/download/2.4.107/wiki-js.tar.gz

2. Extract the package to the final destination of your choice:

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

3. Rename the sample config file to config.yml:

mv config.sample.yml config.yml

4. Edit the config file and fill in your database and port settings (Configuration Reference):

vim config.yml

5. Run Wiki.js

node server

Once the server was running, I opened up the page and completed the web based setup. There was an issue with it not being able to see the PEM files at first but this was down to a typo in the config file. Quickly resolved. I hate to tell you developers, but Let's Encrypt is not a viable solution for everyone... You need to give people the choice. Thankfully Wiki.js do have a configuration section in the docs that relates to HTTPS that isn't just LE here: https://docs.requarks.io/install/config#https

It's not perfect, but it will do.

Now we need to make it run as a service. In its current state it will quit when you disconnect from the server. Wiki.js have some documentation on this bit too: https://docs.requarks.io/install/linux#run-as-service although, changes were required here as I was using NVM. This resulted in the service failing to start with a wiki.service: main process exited, code=exited, status=203/EXEC error as it wasn't able to find "node" with the example .service file they provided.

  1. Create a new file named wiki.service inside directory /etc/systemd/system.
vim /etc/systemd/system/wiki.service

2. Paste the following contents (assuming your wiki is installed at)/var/wiki - You can see that I have "Environment" and have changed the "ExecStart":

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

[Service]
Type=simple
Environment=NODE_VERSION=12.x.x
ExecStart=/path/to/nvm/nvm-exec node server
Restart=always
# Consider creating a dedicated user for Wiki.js here:
User=yourwikijsuser
Environment=NODE_ENV=production
WorkingDirectory=/var/wiki

[Install]
WantedBy=multi-user.target

3. Reload systemd and start the service:

systemctl daemon-reload

systemctl enable wiki

systemctl start wiki

There we have it. A CentOS 7 based local installation of Wiki.js with custom certificates, running as a service. This implementation is also using Azure AD authentication https://docs.requarks.io/auth/azure.

It's worth noting here that this may not be the perfectly secure setup. However, it is limited to internal use only to select users connected through a certain VPN which reduces the risk somewhat but outgoing traffic is allowed. I am open to suggestions on improvements though!

Show Comments