We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install Wiki.js on Ubuntu 22.04|20.04|18.04 with Let’s Encrypt SSL

Learn how to – Install Wiki.js on Ubuntu 22.04|20.04|18.04 with Let’s Encrypt SSL.

This guide demonstrates how to install Wiki.js on Ubuntu 22.04|20.04|18.04 with Let’s Encrypt SSL. Wiki and Wikipedia are two different entities. A wiki is software used in collaborative writing and editing while Wikipedia is a website that adheres to the Wiki format. There are many Wiki engines such as DokuWiki, TiddlyWiki, PmWiki, Wikkawiki e.t.c

Wiki.js is one of the open-source, powerful, and modern Wiki engines based on Node.js, Git, and Markdown. It is released under the Affero GNU General Public License. Wiki.js offers support for various databases such as MySQL, MariaDB, and MSSQL with the primary support for PostgreSQL.

The cool features associated with Wiki.js are:

  • It is fairly easy to use with the ability to edit content in a simple Markdown format
  • Multi-lingual content support with full support for RTL languages like Arabic, Hebrew, and Persian.
  • Full support for content backup and synchronization for multi-vendors like Google Drive, Microsoft OneDrive, AWS S3, Dropbox, Box.net, and DigitalOcean Spaces.
  • Git-backed storage.
  • It has a search functionality as a built-in feature.
  • Intuitive media assets management – media content can be inserted into the content.
  • Supports comments.

Setup Requirements

To be able to install Wiki.js, you need the following:

  • Git 2.7.4 or later
  • Node.js 10 or later. Odd-numbered versions such as 11.x, 13.x, 15.x, 17.x are not supported.
  • Minimum of 1GB RAM
  • A web server such as Nginx, Apache e.t.c
  • A database server such as PostgreSQL 9.5 or later, MariaDB 10.2.7 or later, MySQL 8.0 or later, MS SQL 2012 or later, and SQLite 3.9 or later
  • Domain name with A/AAAA records set up for HTTPS

1. Install Git on Ubuntu 22.04|20.04|18.04

Wiki.js requires Git 2.7.4 and above installed on Ubuntu 22.04|20.04|18.04. This can be achieved by executing the command:

sudo apt install git

Alternatively, you can install the latest version by adding a third-party repository to your system.

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt update
sudo apt install git

Once installed, check the version.

$ git --version
git version 2.25.1

2. Install Node.js on Ubuntu 22.04|20.04|18.04

For Wiki.js to run, we need even-numbered Node.js above 10.x installed. The most recommended way is to install it from the NodeSource repositories.

Enable the NodeSourcerepository on Ubuntu 22.04|20.04|18.04 using the command:

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

With the repository enabled, install the LTS Node.js using the command:

sudo apt-get install -y nodejs

Once complete, verify the installed versions:

$ node -v && npm -v
v16.14.2
8.5.0

3. Install and Configure MariaDB on Ubuntu 22.04|20.04|18.04

Since the supported version is MariaDB 10.2.7 or later, we will install MariaDB 10.6 on our Ubuntu 22.04|20.04|18.04 system.

Begin by adding the repository:

sudo apt install software-properties-common -y
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup

Now proceed and install MariaDB Database server.

sudo apt update
sudo apt install mariadb-server mariadb-client

Once installed, start and enable MariaDB:

sudo systemctl start mariadb   
sudo systemctl enable mariadb  

Harden the instance using the command:

$ sudo mariadb-secure-installation 
Enter current password for root (enter for none): Press Enter
Switch to unix_socket authentication [Y/n] Y
Change the root password? [Y/n] Y
New password: <NEW-PASSWORD>
Re-enter new password: <CONFIRM-NEW-PASSWORD>
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Thanks for using MariaDB!

Login to the MariaDB shell with the password created above.

mysql -u root -p

Now create a database for Wiki.js.

CREATE DATABASE wikidb;
CREATE USER 'wikidb_user'@'localhost' IDENTIFIED BY 'Passw0rd';
GRANT ALL ON wikidb.* TO 'wikidb_user'@'localhost' WITH GRANT OPTION;
FLUSH privileges;
EXIT

4. Download Wiki.js on Ubuntu 22.04|20.04|18.04

To enhance security, we will begin by creating a dedicated user for Wiki.js and Node.js processes.

The user can be created with the command:

sudo adduser wikijs

Create a folder for the wiki.js source code.

sudo mkdir -p /var/www/wikijs

The created user will own the source code folder.

sudo chown wikijs:wikijs /var/www/wikijs

Now switch to the created user and downloaded the latest Wiki.js source code.

sudo su - wikijs
cd /var/www/wikijs
wget https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz

Once the download is complete, extract the archive.

tar xzf wiki-js.tar.gz
rm wiki-js.tar.gz

5. Configure Wiki.js on Ubuntu 22.04|20.04|18.04

The wiki.js configuration file will be created from the sample config file as below:

cp config.sample.yml config.yml

Now make the desired adjustments to the created config file:

vim config.yml

To accommodate the created MariaDB database, make the below changes to the file:

db:
  type: mariadb

  # PostgreSQL / MySQL / MariaDB / MS SQL Server only:
  host: localhost
  port: 3306
  user: wikidb_user
  pass: Passw0rd
  db: wikidb
  ssl: false
.....
# Leave 0.0.0.0 for all interfaces
bindIP: 127.0.0.1

Remember to replace the correct database credentials. Also, change the Bind IP to 127.0.0.1 for security reasons since we will be using Nginx as a reverse proxy.

Once the settings have been made, verify if the server is running correctly.

node server

Sample Output:

Stop the running server using CTRL + C. Also switch back to the previous sudo user and p[reoceed with the setup.

exit

6. Create a Systemd Service for Wiki.js on Ubuntu 22.04|20.04|18.04

For us to be able to manage the wiki.js service, we need to create a systemd service file.

sudo vim /etc/systemd/system/wikijs.service

The file will contain the below lines.

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

[Service]
Type=simple
ExecStart=/usr/bin/node server
Restart=always

User=wikijs
Environment=NODE_ENV=production
WorkingDirectory=/var/www/wikijs

[Install]
WantedBy=multi-user.target

Save the file and reload the system daemon.

sudo systemctl daemon-reload

Start and Enable the wiki.js service:

sudo systemctl start wikijs
sudo systemctl enable wikijs

Check the status of the service:

$ systemctl status wikijs
● wikijs.service - Wiki.js
     Loaded: loaded (/etc/systemd/system/wikijs.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-04-21 10:49:25 UTC; 6s ago
   Main PID: 29258 (node)
      Tasks: 11 (limit: 4612)
     Memory: 80.8M
     CGroup: /system.slice/wikijs.service
             └─29258 /usr/bin/node server
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.401Z [MASTER] warn: DB Configuration is empty or incomplete. Switching to Setup mode...
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.402Z [MASTER] info: Starting setup wizard...
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.498Z [MASTER] info: Starting HTTP server on port 3000...
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.498Z [MASTER] info: HTTP Server on port: [ 3000 ]
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.500Z [MASTER] info: HTTP Server: [ RUNNING ]
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.501Z [MASTER] info:  
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.501Z [MASTER] info:
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.501Z [MASTER] info: Browse to http://YOUR-SERVER-IP:3000/ to complete setup!
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.501Z [MASTER] info:
Apr 21 10:49:26 ubuntu node[29258]: 2022-04-21T10:49:26.502Z [MASTER] info:  

7. Install and Configure Nginx on Ubuntu 22.04|20.04|18.04

In this guide, we will use the high-performance Nginx server for reverse proxy. Install Nginx using the command:

sudo apt install nginx

Create the virtual host file for Wiki.js.

sudo vim /etc/nginx/conf.d/wikijs.conf

The file will contain the below lines:

server {
  listen 80;
  server_name  wiki.example.com;
  root   /var/www/wikijs;

  # Pass requests to the Wiki.js service listening on 127.0.0.1:3000
  location / {
    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_set_header    Host $host;
    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;
  }
}

Check the syntax of the file:

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart and enable Nginx:

sudo systemctl restart nginx
sudo systemctl enable nginx

8. Access the wiki.js Web UI

Proceed and access the Wiki.js service from the browser using the URL http://IP_address or http://domain_name

Create the admin account and install Wiki.js. Once the installation is complete, you will be redirected to the login page. Provide the admin credentials to log in.

For the first time when you log in, you have the two options below, create a home or proceed to the administration panel.

Here, we will create the first page by clicking on +Create Home Page.

I will prefer the Markdown editor here.

Provide the desired title and description for your page.

Now provide the content for the created page.

Click create and you will have your page as below.

On this page, you can still add a new page by clicking on the +icon in the top right corner. To visit the administration dashboard use the settings icon in the top right corner.

Here, get to view the available pages, edit the theme, manage users, groups e.t.c.

9. (Optional) – Secure Wiki.js with Let’s Encrypt SSL

This step can only be accomplished if you have a Fully Qualified Domain Name. Let’s Encrypt is used to issue free trusted certificates for a domain name. First, install Certbot for Nginx.

sudo apt install certbot python3-certbot-nginx

Proceed and issue SSL certificates using the command:

sudo certbot --nginx

Proceed as below:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): Enter a valid Email address here          

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: wiki.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1

Requesting a certificate for wiki.example.com
Performing the following challenges:
http-01 challenge for wiki.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/wikijs.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/wikijs.conf

Successfully received certificate.
Certificate is saved at: a2enmod ssl
/etc/letsencrypt/live/wiki.example.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/wiki.example.com/privkey.pem
This certificate expires on 2022-07-18.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

After this, proceed and access your site via HTTPS. The padlock icon shows that the site is secure.

That was enough learning! I hope this guide on how to install Wiki.js on Ubuntu 22.04|20.04|18.04 with Let’s Encrypt SSL was significant to you.

Related posts:

Cart

Your Cart is Empty

Back To Shop