Skip to main content

Install Uptime Kuma on Ubuntu with Node.js and Nginx

One of the first steps is to install Node.js on Ubuntu but before you do so make sure your server is updated. Please run the x2 commands below before following the tutorial.

sudo apt update && apt-get upgrade -y

Once your OS is updated, you can run the below command to install Node.js:

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt install -y nodejs

Once Node.js is installed, you will need to clone the Git Repo of Uptime Kuma, however before doing that make sure you have Git installed with the below command:

sudo apt update && sudo apt install -y git

To clone the Uptime Kuma GitHub repository locally, please run the below command in your terminal which will clone the latest release:

git clone https://github.com/louislam/uptime-kuma.git

Make a note of the directory where you cloned the repository e.g. /home and navigate to it.

cd /home/uptime-kuma

Once you are in the relevant directory you need to run the setup script along with the PM2 process manager which will keep Uptime Kuma running:

npm run setup
npm install pm2 -g 

We also recommend setting up log rotation with the below command as logs will help you troubleshoot if any issues arise:

pm2 install pm2-logrotate

Once you have the above setup, it is now time to start Uptime Kuma with a simple command below and to ensure that if you ever reboot your server, Uptime Kuma starts back automatically:

pm2 start server/server.js --name uptime-kuma
pm2 startup

To make sure Uptime Kuma can be accessed via the browser and a domain name, Nginx or Apache needs to be setup as a reverse proxy, in this case we will be using Nginx:

apt install nginx -y

Once Nginx has been installed, make sure it is installed and running the latest version with the below commands:

nginx -v
systemctl status nginx

Now you have to create a Nginx configuration file, also known as a “conf” file with the below contents that you can copy and paste, you can either use Vim or Nano editor:

nano /etc/nginx/conf.d/uptime-kuma.conf

Configuration file contents with improved security added along with performance enhancements, replace “uptime-kuma.yourdomainname.com” with your own domain name if you have one: