How Do You Deploy Wiki JS on Ubuntu 18.04 With Nginx Web Server?

//

Heather Bennett

Deploying Wiki JS on Ubuntu 18.04 with Nginx web server is a straightforward process that allows you to create and manage your own wiki pages. In this tutorial, we will guide you through the steps required to set up and configure Wiki JS on your Ubuntu server.

Step 1: Update System Packages

Before we begin, let’s update the system packages to ensure that we have the latest software versions installed. Open a terminal window and run the following commands:


$ sudo apt update
$ sudo apt upgrade

Step 2: Install Node.js

In order to run Wiki JS, we need to install Node.js on our system. Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. To install Node.js, follow these steps:

  1. Add the NodeSource repository:
  2. 
       $ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
       
  3. Install Node.js:
  4. 
       $ sudo apt install -y nodejs
       

Step 3: Install and Configure Nginx

Nginx is a popular web server that will act as a reverse proxy for our Wiki JS application. To install Nginx, use the following command:


$ sudo apt install -y nginx

Once Nginx is installed, we need to configure it to serve our Wiki JS application. Create a new Nginx server block configuration file by running:


$ sudo nano /etc/nginx/sites-available/wikijs

Add the following configuration to the file:


server {
    listen 80;
    server_name your_domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Save the file and exit the text editor.

Create a symbolic link to enable the Nginx server block configuration:


$ sudo ln -s /etc/nginx/sites-available/wikijs /etc/nginx/sites-enabled/

Test the Nginx configuration for syntax errors:


$ sudo nginx -t

If there are no errors, restart Nginx to apply the changes:


$ sudo systemctl restart nginx

Step 4: Install and Configure Wiki JS

Now we are ready to install Wiki JS. Follow these steps:

  1. Create a new system user:
  2. 
       $ sudo adduser --system --shell /bin/bash wikijs
       
  3. Create a new directory for Wiki JS:
  4. 
       $ sudo mkdir /var/www/wikijs
       
  5. Change ownership of the directory to the wikijs user:
  6. 
       $ sudo chown wikijs:wikijs /var/www/wikijs
       
  7. Switch to the wikijs user:
  8. 
       $ sudo su - wikijs
       
  9. Download and extract the latest version of Wiki JS:
  10. 
       $ wget https://github.com/Requarks/wiki/releases/download/2.5.238/wiki-js.tar.gz
       $ tar xvfz wiki-js.gz
       
  11. Install dependencies and build Wiki JS:
  12. 
       $ cd wiki-js
       $ npm install --production
       

Step 5: Configure Wiki JS

To configure Wiki JS, we need to edit the configuration file. Copy the sample configuration file provided with Wiki JS:


$ cp config.sample.yml config.yml

Edit the configuration file using a text editor:


$ nano config.yml

Update the following settings in the configuration file:


server:
  host: "0.0.0"
  port: 3000

db:
  type: "sqlite"
  path: "/var/www/wikijs/database.db"

auth:
  methods:
    - "password"
  password:
    - "your_password"

Step 6: Start Wiki JS

Switch back to the root user:


$ exit

Start Wiki JS using PM2 process manager:


$ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u wikijs --hp /var/www/wikijs
$ sudo systemctl start wikijs

You have successfully deployed Wiki JS on your Ubuntu 18.04 server with Nginx as a reverse proxy. You can now access your Wiki JS application by visiting your domain name or IP address in a web browser.

Conclusion

In this tutorial, we learned how to deploy Wiki JS on Ubuntu 18.04 with Nginx as a web server. We covered the installation of Node.js, configuration of Nginx, installation and configuration of Wiki JS, and finally starting the application. Now you can create and manage your own wiki pages using this powerful open-source tool!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy