How to Install Umami on Ubuntu Server

Umami is a self-hosted analytics platform designed for use on web servers. In this tutorial, we'll walk through the process of installing Umami on Ubuntu Server Latest.

Prerequisites

Before we get started, there are a few things you'll need:

  1. A server running Ubuntu Server Latest with root access.
  2. A domain name or subdomain set up to serve Umami.
  3. A valid SSL certificate for your domain (Let's Encrypt is a great option).

Step 1: Install Required Packages

First, we need to install the packages necessary to run Umami. Open your terminal and connect to your server, then run the following commands:

sudo apt-get update

sudo apt-get install nodejs npm mysql-server

This will update your package lists and install Node.js, npm, and MySQL.

Step 2: Install Umami

Next, we'll install Umami. In your terminal, run the following commands:

sudo npm install -g umami

This will install the Umami package globally.

Step 3: Create the Umami Database

Now that we've installed Umami, we need to create a database in MySQL for it to use. In your terminal, run the following command:

sudo mysql

This will open up the MySQL client. Enter the following commands to create a new database for Umami:

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

Note that you should replace "password" with a secure password of your choosing.

Step 4: Configure Umami

Now it's time to configure Umami to use our newly created database. In your terminal, navigate to the directory where you want to install Umami (for example, /var/www/umami) and run the following command:

umami config

This will launch the Umami configuration wizard. Follow the prompts to input your database information, domain or subdomain, and email address for Let's Encrypt to use for your SSL certificate.

Step 5: Run Umami

You're now ready to run Umami! In your terminal, navigate to the Umami installation directory and run the following command:

umami start

This should start the Umami server. You can test it by navigating to your domain or subdomain in a web browser.

Step 6: Set Up Reverse Proxy and SSL

Finally, we need to set up a reverse proxy and SSL for Umami. You can accomplish this with a tool like Nginx or Apache. Here is a sample Nginx configuration file:

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;
  }
}

This configuration file listens for requests on HTTPS, sets up SSL using the Let's Encrypt certificate we created earlier, and forwards any requests to Umami running on port 3000.

Conclusion

That's it! You've now installed and configured Umami on your Ubuntu Server, and set up a reverse proxy and SSL for it. You should now be able to access Umami through your domain or subdomain over HTTPS. Happy tracking!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!