Article

Table of Contents
Theme:
Was this article helpful?

2  out of  2 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

How to Install Umami on Ubuntu 20.04

Last Updated: Thu, Sep 30, 2021
Business Ubuntu Web Servers

Introduction

Umami is a self-hosted web analytics alternative to Google Analytics that focuses on privacy. This guide explains how to install Umami on Ubuntu 20.04.

Requirements

1. Create the Database

  1. SSH to your server as root.
  2. Log in to MySQL as root.

    # mysql -u root
    
  3. Create a umami database and a umami_connect user. Replace StrongPassword with a unique password.

    mysql> CREATE DATABASE umami;
       CREATE USER 'umami_connect'@'localhost' IDENTIFIED WITH mysql_native_password BY 'StrongPassword';
       GRANT ALL PRIVILEGES ON umami.* TO 'umami_connect'@'localhost';
       FLUSH PRIVILEGES;
    
  4. Exit MySQL.

    mysql> QUIT;
    

2. Install Umami

  1. Clone the GitHub repository.

    # git clone https://github.com/mikecao/umami.git
    
  2. Change to the umami directory.

    # cd umami
    
  3. Install the necessary dependencies.

    # npm install
    
  4. Configure the database for Umami. When prompted, enter the password you chose for the umami_connect user.

    # mysql -u umami_connect -p umami < sql/schema.mysql.sql
    
  5. Create an environment file for Umami.

    # nano .env
    
  6. Paste the following to the file. Replace StrongPassword with the password you chose when you created the database. Replace the value of HASH_SALT with a unique value.

    DATABASE_URL=mysql://umami_connect:StrongPassword@localhost:3306/umami
    HASH_SALT=Replace_This_With_A_Unique_Value
    HOSTNAME=127.0.0.1
    PORT=3010
    
  7. Save and exit the file.

  8. Build Umami.

    # npm run build
    
  9. Install PM2 to automatically restart Umami in case of error or reboot.

    # npm install pm2 -g
    
  10. Launch Umami with pm2

    # pm2 start npm --name "umami" -- run start-env
    
  11. Generate a pm2 startup script and save the configuration.

    # pm2 startup
    # pm2 save
    

3. Install Caddy as a Proxy Server

By default, Umami is only accessible from localhost. To expose Umami to the internet, use Caddy to proxy the connection and manage SSL certificates.

  1. Install Caddy.

    # apt install -y debian-keyring debian-archive-keyring apt-transport-https
    
    # curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
    
    # curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
    
    # apt update
    
    # apt install caddy
    
  2. Edit the CaddyFile.

    # nano /etc/caddy/Caddyfile
    
  3. Replace the contents of Caddyfile with the following. Replace umami.example.com with your server's domain name.

    umami.example.com
    
    reverse_proxy 127.0.0.1:3010
    
  4. Save and exit the file.

  5. Start Caddy.

    # caddy run
    
  6. Verify Caddy is running and configured to restart after a reboot.

    # systemctl status caddy
    

4. Test Umami

In your web browser, navigate to your server's domain name with HTTPS. For example:

https://umami.example.com

Log in as:

  • Username: admin
  • Password: umami

Next Steps

Please see the Umami documentation to learn how to use your new server.

Want to contribute?

You could earn up to $600 by adding new articles