Install and Configure Uptime Kuma on Ubuntu 24.04

By Anurag Singh

Updated on Jul 24, 2024

Install and Configure Uptime Kuma on Ubuntu 24.04

In this comprehensive tutorial, you will learn how to install and configure Uptime Kuma on Ubuntu 24.04, a self-hosted monitoring tool, on your Ubuntu server. Follow our step-by-step guide to set up Uptime Kuma, ensuring your websites and services are continuously monitored for uptime and performance. From system preparation to secure access configuration with HTTPS

Uptime Kuma is a self-hosted monitoring tool designed to track the uptime and performance of websites and services. It provides real-time status updates, customizable alerting options, and detailed metrics to help ensure your websites and services remain operational. 

Uptime Kuma supports various monitoring types, including HTTP(s), TCP, Ping, and more, making it a versatile solution for monitoring diverse infrastructure. With an intuitive user interface and easy setup, Uptime Kuma is ideal for web administrators and developers seeking a reliable and user-friendly monitoring tool.

Install and Configure Uptime Kuma on Ubuntu

Prerequisites

Step 1: Update Your System

Before installing any software, it’s a good practice to update your system’s package index and upgrade all installed packages to their latest versions.

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and npm

Uptime Kuma is built with Node.js, so you need to have Node.js and npm (Node Package Manager) installed on your server.

Install Node.js from the NodeSource repository:

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

Verify the installation:

node -v
npm -v

Step 3: Clone and Install Uptime Kuma

Install Git if not installed already. Git is required to clone the Uptime Kuma repository.

sudo apt install -y git

Clone the Uptime Kuma repository from GitHub to your server.

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

Let's proceed with the installation process.

Install the required dependencies and build Uptime Kuma.

npm run setup

Step 4: Install and Run PM2

To run Uptime Kuma in the background, you can use a process manager like pm2.

Install pm2 globally:

sudo npm install pm2 -g && pm2 install pm2-logrotate

Start Uptime Kuma with pm2:

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

To ensure Uptime Kuma starts on boot, use the following command:

pm2 startup
pm2 save

Step 5: Configure Firewall 

If you have enabled firewall, you need to add HTTP and HTTPS ports in the firewall.

ufw allow 80/tcp
ufw allow 443/tcp
ufw reload

Configure SELinux (Optionally)

If you have enabled SELinux in your server, follow this step. 

You can adjust the SELinux policies to allow Nginx to connect to the upstream server:

sudo setsebool -P httpd_can_network_connect 1

Step 6: Install Nginx and Certbot

Install Nginx:

sudo apt install -y nginx

Install Certbot:

sudo apt install -y certbot python3-certbot-nginx

Configure Nginx for Uptime Kuma:

sudo nano /etc/nginx/sites-available/uptime-kuma

Add the following configuration:

server {
    listen 80;
    server_name your_domain;

    location / {
        proxy_pass http://localhost:3001;
        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;
    }
}

Replace your_domain with your actual domain name.

Enable the configuration and restart Nginx:

sudo ln -s /etc/nginx/sites-available/uptime-kuma /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Replace your_domain with your domain name. Obtain an SSL certificate:

sudo certbot --nginx -d your_domain

Follow the prompts to obtain the certificate.

Step 7: Configure Uptime Kuma

Open your web browser and go to https://your_domain. You should see the Uptime Kuma login page.

Create an admin account by filling out the registration form.

Once logged in, you can start adding your monitors. Click on "Add New Monitor" and fill in the required details such as:

  • Friendly Name: A name for the monitor.
  • URL: The URL of the website you want to monitor.
  • Type: Select the type of monitor (HTTP(s), TCP, Ping, etc.).
  • Interval: Set how often you want to check the URL.

After filling in the details, click on "Save" to add the monitor.

Now you can access Uptime Kuma securely via https://your_domain.

Conclusion

In this tutorial, we've seen how to install and configure Uptime Kuma on your Ubuntu 24.04 server. You can now monitor your websites and receive alerts if any of them go down.