Wiki.js is open-source wiki software, it’s powerful and easily extensible, it’s an engine running on node.js and is written in javascript. It’s available as a self-hosted solution or as a single-click install from Digital Ocean and AWS marketplace.
Wiki.js 2 features
- It works on any virtual environment and supports many database platforms such as Postgresql, MariaDB, Mysql, SQLite, Ms Sql.
- It has an extensive and intuitive admin area where you do all your administration duties at a go.
- It is built with performance because of its node.js integration.
- It is easily customizable.
- It can scale easily
Wiki.js 2 requirements
- Server: 2 cores or more and 1 GB RAM
- At least 1 GB of storage space
- Good internet access
- Database: Postgresql 9.5 or later, MariaDB 10.2 or later, MySQL 8 or later, MS SQL Server 2012 or later, SQLite 3.9 or later.
- Node.js 10 version 10 or later, 12 version 12 or later, 14 version 14 or later, and 16 version 16 or later.
Also, you can check out these articles for node.js, PostgreSQL installation.
Install Wiki.js 2 on Ubuntu 20.04
1. Update system repositories
The first thing to do is to update your system repositories so that once you start your installation of Wiki.js 2 you will not run into errors early on. So to update your repo run the following command.
sudo apt -qqy update -y
Then we need to enable our system to be running updates automatically with this command.
sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' dist-upgrade
2. Install Docker
We need to have Docker because it is a highly recommended platform to run wiki.js. So to install Docker check this article on how to install docker on Ubuntu 20.04.
Install Docker Dependencies
To start installing Docker, we first need to have dependencies. To install dependencies run the following command.
sudo apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install apt-transport-https ca-certificates curl gnupg-agent software-properties-common openssl
Sample output
ca-certificates is already the newest version (20210119~20.04.2).
curl is already the newest version (7.68.0-1ubuntu2.7).
curl set to manually installed.
openssl is already the newest version (1.1.1f-1ubuntu2.12).
openssl set to manually installed.
software-properties-common is already the newest version (0.99.9.8).
software-properties-common set to manually installed.
apt-transport-https is already the newest version (2.0.6).
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
gnupg-agent
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 5232 B of archives.
After this operation, 46.1 kB of additional disk space will be used.
Selecting previously unselected package gnupg-agent.
(Reading database ... 94889 files and directories currently installed.)
Preparing to unpack .../gnupg-agent_2.2.19-3ubuntu2.1_all.deb ...
Unpacking gnupg-agent (2.2.19-3ubuntu2.1) ...
Setting up gnupg-agent (2.2.19-3ubuntu2.1) ...
Add Registry Key and add repository deb package
To register the Docker package registry we need to add a signing key and add it to the deb package repository.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the package to the apt repository.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
After this, run the system repository and install docker-ce
sudo apt -qqy update
# install docker
sudo apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install docker-ce docker-ce-cli containerd.io
3. Setup Wiki.js 2 containers
First, we need to create a wiki.js 2 installation directory with the following command.
mkdir -p /etc/wiki
Now we need to generate a database secret like this
openssl rand -base64 32 > /etc/wiki/.db-secret
Then we need to create docker internal networks for wiki.js 2 to use.
docker network create wikinet
Then create a data volume for PostgreSQL.
docker volume create pgdata
And lastly, create the actual containers like this.
For database container
docker create --name=db -e POSTGRES_DB=wiki -e POSTGRES_USER=wiki -e POSTGRES_PASSWORD_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -v pgdata:/var/lib/postgresql/data --restart=unless-stopped -h db --network=wikinet postgres:14
Output
Unable to find image 'postgres:14' locally
14: Pulling from library/postgres
ae13dd578326: Pull complete
723e40c35aaf: Pull complete
bf97ae6a09b4: Pull complete
2c965b3c8cbd: Pull complete
c3cefa46a015: Pull complete
64a7315fc25c: Pull complete
b9846b279f7d: Pull complete
ed988fb8e7d9: Pull complete
ed4bb4fd8bb5: Pull complete
ead27f1733c8: Pull complete
7d493bacd383: Pull complete
0920535e8417: Pull complete
db76d5bdbf2c: Pull complete
Digest: sha256:14a621708fddaf5620fb3dea3e313e8afc3615b6fe0b824ff929692823952144
Status: Downloaded newer image for postgres:14
4f1744020e8ee16c6180cbb469f527fc04a83f47224bb9a0b84c7e1aeeb6a9af
For Wiki container
docker create --name=wiki -e DB_TYPE=postgres -e DB_HOST=db -e DB_PORT=5432 -e DB_PASS_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -e DB_USER=wiki -e DB_NAME=wiki -e UPGRADE_COMPANION=1 --restart=unless-stopped -h wiki --network=wikinet -p 80:3000 -p 443:3443 ghcr.io/requarks/wiki:2
# output
Unable to find image 'ghcr.io/requarks/wiki:2' locally
2: Pulling from requarks/wiki
59bf1c3509f3: Pull complete
683dd8c3cc08: Pull complete
ae5b2724f19b: Pull complete
39190df3f477: Pull complete
d4cce20361a2: Pull complete
4f4fb700ef54: Pull complete
85ad99a67650: Pull complete
11d5b98621fc: Pull complete
444c84d6e4a9: Pull complete
e90aa5f15768: Pull complete
aaa0b712706c: Pull complete
f54da04ffb2d: Pull complete
13bd7779ec0d: Pull complete
Digest: sha256:6e2cd07652e3a96d305cb8ddd3e6ea649d99ecb3df2988f733ac621b2cbf910e
Status: Downloaded newer image for ghcr.io/requarks/wiki:2
1a12af5878318163fcf6a1d8805a9ec3421df6528fb279d142c88d147e0e407e
For wiki update companion
docker create --name=wiki-update-companion -v /var/run/docker.sock:/var/run/docker.sock:ro --restart=unless-stopped -h wiki-update-companion --network=wikinet requarks/wiki-update-companion:latest
# output
Unable to find image 'requarks/wiki-update-companion:latest' locally
latest: Pulling from requarks/wiki-update-companion
000eee12ec04: Pull complete
db438065d064: Pull complete
e345d85b1d3e: Pull complete
f6285e273036: Pull complete
2354ee191574: Pull complete
7c8b4b598d87: Pull complete
e436df127cfa: Pull complete
Digest: sha256:ef3c818540fd919b1cda73eef1bc83cb8b08f76e8c26c4ad291a9fa489ba0299
Status: Downloaded newer image for requarks/wiki-update-companion:latest
093d83bfc4903837378bf55c495380b53822beb63b932999c8f5b93fb6647862
4. Setup firewall
We need to allow, https, http and ssh rules to pass the firewall filter. this will allow us ssh from any remote machine and be able to access the interface of the wiki.js easily.
sudo ufw allow ssh
sudo allow http
sudo allow https
sudo ufw --force enable
5. Install and configure NGINX
Nginx is not necessarily needed but it is highly recommended to put it in front of wiki.js. This enables the usage of SSL, caching parameters, etc.
sudo apt install nginx
Adjust the firewall setting to allow Nginx entry.
sudo ufw allow 'Nginx HTTP'
Then we need to enable the service.
sudo systemctl enable nginx
sudo systemctl start nginx.service
sudo systemctl status nginx.service
6. Start the Wiki.js containers
Head over to your terminal and start the docker containers we have created.
docker start db
docker start wiki
docker start wiki-update-companion
Now that we have started the docker containers, head over to your favorite browser and access the wiki.js interface.
http://<your-ip-address>
Conclusion
Congratulations you have successfully installed Wiki.js 2 on Ubuntu 20.04. If in case you face any problems consult Wiki.js documentation.