UbuntuUbuntu Based

How To Install Umami Analytics on Ubuntu 24.04 LTS

Install Umami Analytics on Ubuntu 24.04

In this tutorial, we will show you how to install Umami Analytics on Ubuntu 24.04 LTS. Umami is an open-source web analytics platform that prioritizes user privacy and data ownership. Unlike conventional analytics tools, Umami doesn’t use cookies and is fully compliant with GDPR regulations. This makes it an excellent choice for website owners who want to gather insights without compromising their visitors’ privacy.

Key features of Umami include:

  • Real-time data tracking
  • Customizable dashboards
  • Event tracking
  • Multi-site support
  • Easy integration with existing websites

This guide is designed for system administrators and website owners with basic Linux command-line experience. We’ll cover everything from initial server setup to post-installation configuration, ensuring you have a robust analytics solution up and running.

Prerequisites

Before we begin the installation process, make sure you have the following:

  • A server running Ubuntu 24.04 LTS
  • Root or sudo access to the server
  • A domain name pointed to your server’s IP address
  • Basic familiarity with the command line interface

System requirements for Umami:

  • At least 1 GB of RAM
  • 2 CPU cores
  • 20 GB of storage space

Initial Server Setup

Let’s start by updating your Ubuntu system and installing essential security configurations.

Update and Upgrade System Packages

First, update your package lists and upgrade existing packages:

sudo apt update
sudo apt upgrade -y

Configure Firewall

Enable the UFW firewall and allow SSH, HTTP, and HTTPS traffic:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

Install Essential Dependencies

Now, let’s install the core dependencies required for Umami:

sudo apt install -y nodejs npm postgresql apache2 certbot python3-certbot-apache git

This command installs Node.js, NPM, PostgreSQL, Apache web server, Certbot for SSL, and Git.

Database Configuration

Umami requires a database to store analytics data. We’ll use PostgreSQL for this purpose.

Create a PostgreSQL User and Database

First, switch to the postgres user:

sudo -i -u postgres

Now, create a new database and user for Umami:

createdb umami
createuser -P umami

You’ll be prompted to enter a password for the new user. Choose a strong, unique password and make note of it.

Grant necessary privileges to the umami user:

psql -c "ALTER USER umami WITH SUPERUSER;"

Exit the postgres user session:

exit

Umami Installation Process

With the database set up, we can now proceed to install Umami.

Create a System User for Umami

Create a dedicated user for running Umami:

sudo useradd -r -s /bin/false umami

Clone the Umami Repository

Clone the Umami source code from GitHub:

sudo git clone https://github.com/umami-software/umami.git /var/www/umami

Install Dependencies

Navigate to the Umami directory and install the required Node.js packages:

cd /var/www/umami
sudo npm install

Configure Umami

Create a configuration file for Umami:

sudo cp .env.example .env
sudo nano .env

Edit the .env file with your database details:


DATABASE_URL=postgresql://umami:your_password@localhost:5432/umami

Replace “your_password” with the password you set for the umami database user.

Build the Application

Build the Umami application:

sudo npm run build

Web Server Configuration

We’ll use Apache as a reverse proxy to serve Umami.

Create an Apache Virtual Host

Create a new Apache configuration file:

sudo nano /etc/apache2/sites-available/umami.conf

Add the following configuration:

<VirtualHost *:80>
    ServerName your_domain.com
    ProxyPreserveHost On
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ErrorLog ${APACHE_LOG_DIR}/umami_error.log
    CustomLog ${APACHE_LOG_DIR}/umami_access.log combined
</VirtualHost> 

Replace “your_domain.com” with your actual domain name.

Enable the Virtual Host

Enable the new virtual host and reload Apache:

sudo a2ensite umami.conf
sudo a2enmod proxy proxy_http
sudo systemctl reload apache2

SSL Configuration

Secure your Umami installation with an SSL certificate using Certbot:

sudo certbot --apache -d your_domain.com

Follow the prompts to complete the SSL configuration.

Application Deployment

Now, let’s set up Umami to run as a system service.

Create a Systemd Service File

Create a service file for Umami:

sudo nano /etc/systemd/system/umami.service

Add the following content:

[Unit]
Description=Umami Analytics
After=network.target

[Service]
Type=simple
User=umami
WorkingDirectory=/var/www/umami
ExecStart=/usr/bin/npm start
Restart=on-failure

[Install]
WantedBy=multi-user.target

Start and Enable the Umami Service

Start the Umami service and enable it to run on boot:

sudo systemctl start umami
sudo systemctl enable umami

Post-Installation Setup

With Umami installed and running, it’s time to perform the initial setup.

Access the Umami Dashboard

Open your web browser and navigate to https://your_domain.com. You should see the Umami login page.

Install Umami Analytics on Ubuntu 24.04 LTS

Create an Admin Account

Click on “Create an account” and fill in the required information to create your admin user.

Change Default Credentials

After logging in, go to the settings page and change the default password to a strong, unique password.

Website Integration

To start tracking your website, you need to add the Umami tracking script.

Get the Tracking Code

In the Umami dashboard, go to “Settings” > “Websites” and click “Add website”. Fill in your website details and save.

Copy the provided tracking code.

Troubleshooting Guide

If you encounter issues during the installation or usage of Umami, try these troubleshooting steps:

Database Connection Issues

  • Verify the database credentials in the .env file
  • Ensure PostgreSQL is running: sudo systemctl status postgresql
  • Check PostgreSQL logs: sudo tail -f /var/log/postgresql/postgresql-14-main.log

Web Server Problems

  • Check Apache error logs: sudo tail -f /var/log/apache2/error.log
  • Verify Apache configuration: sudo apache2ctl configtest
  • Ensure the correct ports are open in the firewall

Umami Service Issues

  • Check Umami service status: sudo systemctl status umami
  • View Umami logs: sudo journalctl -u umami
  • Verify Node.js and NPM versions: node -v && npm -v

Maintenance and Updates

To keep your Umami installation secure and up-to-date, follow these maintenance practices:

Regular Backups

Backup your Umami database regularly:

pg_dump -U umami umami > umami_backup_$(date +%Y%m%d).sql

Updating Umami

To update Umami to the latest version:

cd /var/www/umami
sudo git pull
sudo npm install
sudo npm run build
sudo systemctl restart umami

System Updates

Regularly update your Ubuntu system:

sudo apt update
sudo apt upgrade -y

Congratulations! You have successfully installed Umami Analytics. Thanks for using this tutorial for installing the Umami modern analytics platform on Ubuntu 24.04 LTS. For additional help or useful information, we recommend you check the official Umami website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button