Self-Hosted Website Monitoring with Uptime Kuma on Ubuntu 22.04
Posted on August 26th, 2024
In today’s online world, it’s essential for your sites to run smoothly and be available to visitors. When your site goes down, it can result in lost sales, a bad reputation, and unhappy users. No one wants that! To avoid these problems, having a reliable way to monitor your sites is key.
That’s where Uptime Kuma comes in. This open-source tool is perfect for tracking how your project is doing. It has a simple design that makes it easy to use, and the best part is that you can host it yourself. That means you have full control over your monitoring setup. Some important features of Uptime Kuma include:
- Multi-Protocol Support: Monitor your website and services using HTTP(s), TCP, and ICMP (ping) protocols.
- Custom Alerts: Get notified through various channels like email or Discord when your site goes down.
- User-Friendly Dashboard: Easily view the status of all your monitored sites in one place.
- SSL Certificate Monitoring: Keep track of your SSL certificates and receive alerts before they expire.
- Easy Setup: Quickly deploy Uptime Kuma on your server with straightforward installation steps.
In this guide, we’ll show you how to set up Uptime Kuma on Ubuntu 22.04 step by step. Whether you’re a system administrator or a developer, this setup will help you keep an eye on your projects. By the time we finish, you’ll be ready to monitor your site effectively and quickly fix any problems that come up, ensuring a smooth experience for all your visitors.
Before we get started with the installation, there are some prerequisites.
Prerequisites
There are a few things you need to get started with the tutorial.
- Ubuntu 22.04 Server: You can get any Ubuntu 22.04 VPS, Dedicated server or a local installation. If you do not have a server yet, You can check out Linux servers provided by Interserver.
- Root Access or Sudo Access: You need root or sudo access in order to install the packages required to support the UptimeKuma application.
Once you have an Ubuntu server with root or sudo access, You can move forward with the article.
Install UptimeKuma on Ubuntu 22.04
First of all, execute the following commands on your server to update repositories and process pending updates on your system.
$ sudo apt-get update
$ sudo apt-get upgrade -y
It might take a few minutes to process the updates on your server. Once done, we can move forward to set up a tech stack for UptimeKuma.
Install Node.js, NPM and PM2
As uptime kuma is built on Javascript, We need to install and configure Node.js, NPM and PM2 on our Ubuntu server. Here is how we can do it.
Step 1: Download the setup script using the following command.
$ curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
Step 2: Execute the following command to execute the shell script we just downloaded.
$ sudo bash nodesource_setup.sh
Step 3: Now, Execute the following command to install Node.js.
$ sudo apt-get install nodejs -y
Step 4: Finally, Execute the following command to verify the Node.js installation on your server.
$ node -v
If the Node.js is successfully installed, You will be able to see the current node version as an output. You can also check the npm version by executing npm -v
command. Make sure both the commands display you the respective versions without any error.
Install Git (If not Installed already)
We would also need git to clone the UptimeKuma repository. Installing git on ubuntu is very easy. Just execute the following commands to install git on your server.
$ sudo apt-get install git
It will only take less than a minute in any case. Once done, we can move forward with the UptimeKuma installation.
Clone git Repository and Install UptimeKuma
Now, all we have to do is clone the git repository and install the dependencies just like any other Node.js based project. Let’s do it.
Step 1: Execute the following command to clone the repository.
$ git clone https://github.com/louislam/uptime-kuma.git
It will create a new directory named uptime-kuma
in your current directory.
Step 2: Navigate to the project directory using cd
command and execute the following command to install all the dependencies.
$ npm run setup
It might take several minutes to install. Once it is installed, we need to start the project using PM2. Let’s see how do to that.
Step 3: Execute the following command to install pm2 on your server.
$ sudo npm install pm2 -g && pm2 install pm2-logrotate
PM2 installation will hardly take a few minutes. Once the command execution is complete, we can start our UptimeKuma project.
Step 4: Execute the following command to start a server to run UptimeKuma.
$ pm2 start server/server.js --name uptime-kuma
Now, we will create a startup script so that our UptimeKuma instance can boot up automatically when we restart our server in any case.
Step 5: Execute the following command to create a startup script.
$ pm2 startup
Once the command execution is complete, You will be able to access UptimeKuma on the following URL.
http://YOUR_SERVER_IP:3001
Step 6: On the URL, you will see the admin registration form just like the following image. Fill up the required information to complete the setup.
Once the registration is complete, You can start monitoring the uptime of your projects! With the current state, The project set up is complete. You can continue to use it on the IP address.
However, If you want to set up a domain name for UptimeKuma, You can simply set up reverse proxy on Apache or Nginx. You can also set up free SSL certificates using Let’s Encrypt.
Conclusion
Congratulations! You’ve just set up Uptime Kuma on your Ubuntu 22.04 server. Now you have a handy tool to keep an eye on your websites and services, making sure they stay up and running smoothly. Uptime Kuma offers great features like support for different protocols, customizable alerts, and SSL certificate monitoring, so you can stay on top of things and address any issues before they affect your users.
This guide took you through installing Node.js, npm, PM2, and Uptime Kuma, and getting it set up to run automatically. If you want to make things even smoother, consider setting up a domain name and SSL certificates for added security.
With Uptime Kuma up and running, you’re well-equipped to monitor your sites effectively and keep your visitors happy. Enjoy peace of mind knowing you’re on top of your uptime!