Come hang with us on Discord and chat directly with the team!Discordtop-bar-close-icon

2024-08-26

How to Install Umami Analytics on Ubuntu Server

tutorials
img

Are you looking for a powerful, privacy-focused alternative to mainstream analytics tools? Look no further! This comprehensive guide will walk you through the process of installing Umami, a self-hosted analytics platform, on Ubuntu Server Latest. Whether you're a seasoned system administrator or a curious website owner, this step-by-step tutorial will help you set up your own Umami instance in no time.

Why Choose Umami?

1. Privacy-Focused: Keep your data under your control
2. Lightweight: Minimal impact on your website's performance
3. User-Friendly: Easy-to-understand interface and reports
4. Open-Source: Transparent and community-driven development
5. Customizable: Tailor the analytics to your specific needs

Prerequisites

Before we dive in, make sure you have:

- A server running Ubuntu Server Latest
- Root access to your server
- A domain or subdomain pointed to your server
- Basic familiarity with the command line

Step-by-Step Installation Guide

Step 1: Install Required Packages

First, let's update your system and install the necessary packages:


sudo apt-get update
sudo apt-get install nodejs npm mysql-server
 

Step 2: Install Umami

Install Umami globally using npm:


sudo npm install -g umami
 

Step 3: Create the Umami Database

Set up a MySQL database for Umami:


sudo mysql
 

In the MySQL prompt, run:


CREATE DATABASE umami;
CREATE USER 'umami'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON umami.* TO 'umami'@'localhost';
EXIT;
 

Remember to replace 'your_secure_password' with a strong, unique password.

Step 4: Configure Umami

Navigate to your desired installation directory (e.g., /var/www/umami) and run the configuration wizard:


cd /var/www/umami
umami config
 

Follow the prompts to input your database information, domain, and email address for SSL certification.

Step 5: Run Umami

Start the Umami server:


umami start
 

Step 6: Set Up Reverse Proxy and SSL

Configure Nginx as a reverse proxy with SSL. Create a new Nginx configuration file:


sudo nano /etc/nginx/sites-available/umami
 

Add the following configuration (replace umami.example.com with your domain):


server {
  listen 80;
  listen [::]:80;
  server_name umami.example.com;
  return 301 https://$server_name$request_uri;
}

server {
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name umami.example.com;

  ssl_certificate /etc/letsencrypt/live/umami.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/umami.example.com/privkey.pem;

  location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}
 

Enable the configuration and restart Nginx:


sudo ln -s /etc/nginx/sites-available/umami /etc/nginx/sites-enabled/
sudo systemctl restart nginx
 

Conclusion

Congratulations! You've successfully installed Umami on your Ubuntu Server. You can now access your Umami dashboard securely through your domain over HTTPS.

Pro Tips for Umami Success

1. Regular Backups: Set up automated backups of your Umami database.
2. Stay Updated: Keep Umami, Ubuntu, and all components up-to-date for security and new features.
3. Custom Tracking: Explore Umami's API to create custom tracking events for deeper insights.
4. Performance Monitoring: Regularly check your server's performance to ensure smooth operation.

By following this guide, you've taken a significant step towards owning your website analytics data. Umami's powerful features, combined with the stability of Ubuntu Server, create an excellent environment for privacy-focused web analytics.

Remember to respect user privacy and comply with relevant data protection regulations when collecting and analyzing website data.

Happy tracking with Umami on Ubuntu Server!