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:
- Add the NodeSource repository:
- Install Node.js:
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
$ 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:
- Create a new system user:
- Create a new directory for Wiki JS:
- Change ownership of the directory to the wikijs user:
- Switch to the wikijs user:
- Download and extract the latest version of Wiki JS:
- Install dependencies and build Wiki JS:
$ sudo adduser --system --shell /bin/bash wikijs
$ sudo mkdir /var/www/wikijs
$ sudo chown wikijs:wikijs /var/www/wikijs
$ sudo su - wikijs
$ wget https://github.com/Requarks/wiki/releases/download/2.5.238/wiki-js.tar.gz
$ tar xvfz wiki-js.gz
$ 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!