billysoftacademy.com

Learn how to Install Umami Analytics on Ubuntu 22.04 LTS

Introduction

Umami is a modern and stylish analytics platform that is open-source and designed to help website owners and developers gain insights into user behavior and engagement. Unlike traditional analytics solutions, Umami prioritizes privacy and offers a self-hosted alternative which gives you complete control over your data without compromising functionality or usability. With Umami, you can set up your own analytics platform, track website traffic, monitor user interactions, and analyze key metrics, all within a secure and customizable environment. In this guide, we will take you through the step-by-step process of installing Umami on Ubuntu 22.04.

Requirements

The following is a list of items needed to complete the installation successfully:
1) A computer with 4GB RAM, a dual core processor and 50GB of free disk space
2) Cloud servers: A domain name and a public IPv4 or IPv6 address
3) Linux Ubuntu 22.04 LTS or any newer version
4) An SSH client such as Putty
5) A stable internet connection

Overview

The following is an overview of the steps covered in this guide:
1) Updating the system
2) Installing nodejs and mariadb.
3) Downloading Umami software.
4) Configuring NGINX web server for umami.
5) Logging into the Umami webadmin dashboard.

Step 1: Updating the system

The first step of this installation is updating the Linux ubuntu server repository. You can do this by running the command:

sudo apt update -y

Once the update process completes, run the following command to upgrade system packages to their latest available versions:

sudo apt upgrade -y

When the upgrade process completes, restart and reconnect the Ubuntu server.

Step 2: Installing NodeJS and MariaDB server

To begin installing the necessary dependencies for your server, you will need to follow the steps below.

Step 1: Install Node.js

To start, use the following command to install all required dependencies:

apt install wget curl nano ufw software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release debian-archive-keyring unzip -y

Afterward, add the Node.js GPG key:

curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg

Then, add the Node.js repository to APT:

echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list

Now, update the repository and install Node.js:

apt update
apt install nodejs

Verify the Node.js version with the following command:

node --version

Output:

v20.11.0

Step 2: Install MariaDB Server

To start, install the MariaDB database server:

apt install mariadb-server -y

Once MariaDB is installed, log in to the MariaDB console:

mysql

After logging in, create a database and user for Umami:

CREATE USER 'umamiuser'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE umami;

Then, grant all necessary privileges to the Umami database:

GRANT ALL PRIVILEGES ON umami.* TO 'umamiuser'@'localhost';
GRANT ALL ON *.* TO 'umami'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Next, flush the privileges to apply the changes:

FLUSH PRIVILEGES;

Finally, exit the MariaDB console:

EXIT;

Step 3: Download Umami software

To download Umami, follow these steps:

Step 1: Install the Yarn package by running the command:

npm install -g yarn

Step 2: Download the latest version of Umami from the Git repository by running the command:

git clone https://github.com/mikecao/umami.git

Once the download is completed, navigate to the Umami directory and install all required dependencies by running the command: `cd umami` followed by:

yarn install

Step 3: Generate a secret key by running the command:

openssl rand 30 | openssl base64 -A

The output will be the secret key that you will use later.

Step 4: Edit the `.env` file by running the command: `nano .env`. Define your database and secret as shown below:

DATABASE_URL=mysql://umamiuser:password@localhost:3306/umami
APP_SECRET=
DISABLE_TELEMETRY=1
TRACKER_SCRIPT_NAME=custom

Step 5: Run the following command to bundle the app into static files for production:

yarn build

Step 6: Install PM2 to manage your application by running the command:

yarn global add pm2

Step 7: Start the Umami application using PM2 by running the command:

pm2 start yarn --name umami -- start

The output will show the status of the application.

Step 4: Configuring NGINX web server for umami

In order to access Umami from the outside world, you need to configure Nginx as a reverse proxy. Here’s how you can do it:

Step 1: Install the Nginx web server using the following command:

apt install nginx

Step 2: Create an Nginx virtual host file by running the following command:

nano /etc/nginx/conf.d/umami.conf

Step 3: Add the following configurations to the file:

server {
    listen       80;
    server_name  umami.example.com;

    access_log  /var/log/nginx/umami.access.log;
    error_log   /var/log/nginx/umami.error.log;
    
    location / {
      proxy_pass http://localhost:3000;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Step 4: Save the file and then edit the Nginx main configuration file using the following command:

nano /etc/nginx/nginx.conf

Add the following line after the line `http{`:

server_names_hash_bucket_size  64;

Step 5: Save and close the file, and then verify the Nginx for any syntax errors using the following command:

nginx -t

The output should be:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Step 6: Finally, reload Nginx to implement the changes using the following command:

systemctl restart nginx

Step 5: Logging into the Umami webadmin dashboard.

To access the Umami dashboard, open your web browser and enter the following URL in the address bar: http://umami.example.com. Once the page loads, you will be prompted to log in. Use “admin” as the username and “umami” as the password, and then click on the “Login” button to proceed. After successful authentication, you will be redirected to the Umami dashboard.

Conclusion

In this guide, we have walked you through the step-by-step process of installing and configuring Umami, an open-source analytics platform, on Ubuntu 22.04. By following these steps, you will have a self-hosted analytics solution that gives you complete control over your data while still offering powerful features and functionality. Umami is a user-friendly and privacy-focused alternative to traditional analytics platforms, making it a great choice for website owners and developers who value data ownership and security.
Scroll to Top