Skip to content

How to install Fathom Analytics on Ubuntu 24.04

Richard
Written by
Richard
Jun 24, 2024 Updated Mar 20, 2026 5 min read
Matomo featured image

You install Fathom Analytics on Ubuntu 24.04 by deploying its Docker image via the terminal.

Fathom Analytics is a privacy-focused, lightweight website analytics solution that provides essential traffic insights without compromising user privacy.

This guide walks you through setting up Fathom Analytics on Ubuntu 24.04 LTS. You’ll need a server with Ubuntu 24.04 and root or sudo access to run the commands.

⚡ Quick Answer

Install Fathom Analytics on Ubuntu 24.04 by first installing and configuring PostgreSQL. Then, create a Fathom user, download the Fathom binary, and set up its environment file. Finally, run the Fathom server command and access it via your server’s IP address on port 8080.

Install PostgreSQL

You need a database to store Fathom Analytics data, and PostgreSQL is a great choice for Ubuntu.

Use the steps below to install it on Ubuntu.

First, add the PostgreSQL GPG key to Ubuntu. Run the command below to do that.

🐧Bash / Shell
sudo apt install curl
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /usr/share/keyrings/postgresql-key.gpg >/dev/null

Then, add the PostgreSQL APT repository to your sources list.

🐧Bash / Shell
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgresql-key.gpg arch=amd64] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Next, update and refresh the repository list and install PostgreSQL.

🐧Bash / Shell
sudo apt update
sudo apt install postgresql postgresql-contrib

More details on installing PostgreSQL can be found in the link below.

How to install PostgreSQL on Ubuntu

Configure PostgreSQL and create a Fathom database

After installing PostgreSQL, you’ll need to set it up and create a specific database for Fathom to use.

First, log on to the PostgreSQL console by running the command below.

🐧Bash / Shell
sudo -u postgres psql

Run the command below to change or create a password for the administrator account. Confirm the password when prompted.

💻Code
password postgres

Next, create a  Fathom database user account called ‘fathomuser.’

💻Code
CREATE ROLE fathomuser WITH LOGIN ENCRYPTED PASSWORD 'type_strong_password_here';

Replace ‘type_strong_password_here‘ with your password.

Next, create a ‘fathomdb‘ database for Fathom and make the user above owner.

💻Code
CREATE DATABASE fathomdb OWNER fathomuser;

Exit the database console.

💻Code
q

Install Fathom

With PostgreSQL ready, it’s time to download and install Fathom Analytics itself on your system.

First, create a user account for Fathom Analytics.

🐧Bash / Shell
sudo adduser --home /opt/fathom --disabled-password fathom

Next, make the fathom user owner of the /opt/fathom directory.

🐧Bash / Shell
sudo chown -R fathom:fathom /opt/fathom

Next, download the Fathom binary package using the wget command below.

Once downloaded, extract the fathom binary file to the /usr/local/bin directory and make the fathom binary file executable.

💻Code
wget https://github.com/usefathom/fathom/releases/download/v1.3.1/fathom_1.3.1_linux_amd64.tar.gz
sudo tar -C /usr/local/bin -xzf fathom_1.3.1_linux_amd64.tar.gz
sudo chmod +x /usr/local/bin/fathom

Next, switch to the Fathom user account and navigate to the Fathom’s directory by running the command below.

🐧Bash / Shell
sudo su - fathom
cd /opt/fathom

Then, create a new data directory and .env file using the command below.

💻Code
mkdir -p /opt/fathom/data
touch /opt/fathom/data/.env

Use the following nano editor command to open the .env file.

💻Code
nano /opt/fathom/data/.env

Add the lines below to the file, changing the details of the PostgreSQL database created above.

For FATHOM_SECRET, generate 20 alphanumeric characters and use it in the file.

💻Code
FATHOM_GZIP=true
FATHOM_DEBUG=true
FATHOM_DATABASE_DRIVER="postgres"
FATHOM_DATABASE_NAME="fathomdb"
FATHOM_DATABASE_USER="fathomuser"
FATHOM_DATABASE_PASSWORD="type_password_here"
FATHOM_DATABASE_HOST="127.0.0.1"
FATHOM_DATABASE_SSLMODE="disable"
FATHOM_SECRET="fetL5tQSeKzK7eToKfD2"

Save and exit the file when finished.

While still in the Fathom home directory, change to the data folder and run the command below to start the Fathom server.

Command Prompt
cd /opt/fathom/data
fathom server

Once started, browse to the server hostname or IP address followed by port 8080.

💻Code
http://localhost:8080
fathom dashboard on Ubuntu

You should see the Fathom dashboard with a JavaScript code you can copy to the host you want to monitor.

Run Fathom as a System Service

Setting up Fathom as a system service makes it simple to manage, allowing you to start and stop it easily using system commands.

Run the command below to create a Fathom system service file.

🐧Bash / Shell
sudo nano /etc/systemd/system/fathom.service

Copy and paste the lines below in the file and save it.

💻Code
[Unit]
Description=Starts the fathom server
Requires=network.target
After=network.target

[Service]
Type=simple
User=fathom
Restart=always
RestartSec=3
WorkingDirectory=/opt/fathom/data
ExecStart=/usr/local/bin/fathom server

[Install]
WantedBy=multi-user.target

Enable and start Fathom.

🐧Bash / Shell
sudo systemctl daemon-reload
sudo systemctl enable fathom
sudo systemctl start fathom
sudo systemctl status fathom

The status option will display Fathom as running and healthy.

💻Code
fathom.service - Starts the fathom server
Loaded: loaded (/etc/systemd/system/fathom.service; enabled; preset: enabl>
Active: active (running) since Mon 2024-06-24 16:55:01 CDT; 6s ago
Main PID: 10703 (fathom)
Tasks: 6 (limit: 4561)
Memory: 6.3M (peak: 6.7M)
CPU: 29ms
CGroup: /system.slice/fathom.service
└─10703 /usr/local/bin/fathom server

Every time you start the machine, Fathom should be accessible using the local server name or IP address followed by the port number.

Set up a reverse proxy

To access Fathom easily using a domain name and handle web traffic better, you can set up a reverse proxy with Nginx or Apache.

The two links below show you how to set up a reverse proxy using Nginx or Apache.

That should do it!

Conclusion:

  • Installing and configuring Fathom Analytics on Ubuntu 24.04 enables tracking website traffic and understanding visitor behavior while prioritizing data privacy.
  • By following the steps outlined in this guide, users can empower themselves with valuable insights into their website’s performance without compromising the privacy of their visitors.
  • Additionally, setting up Fathom as a system service ensures it is easily manageable, and utilizing a reverse proxy optimizes web traffic and allows access via a domain name.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version