How To Install Fathom Analytics on Ubuntu 24.04 LTS
In this tutorial, we will show you how to install Fathom Analytics on Ubuntu 24.04 LTS. In today’s digital landscape, website owners and administrators understand the importance of tracking and analyzing visitor data to make informed decisions and optimize their online presence. However, with growing concerns about privacy and data security, many are seeking alternatives to traditional web analytics platforms. Enter Fathom Analytics, a privacy-focused, open-source web analytics solution that provides valuable insights without compromising user privacy.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of Fathom Analytics on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- At least 4 GB of RAM and 20 GB of free disk space.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
- An Ubuntu 24.04 system with root access or a user with sudo privileges.
Install Fathom Analytics on Ubuntu 24.04 LTS
Step 1. Updating the Package Repository.
To ensure a smooth installation process and maintain the security of your server, it is crucial to update and upgrade your system to the latest available packages. Open a terminal and run the following commands:
sudo apt update sudo apt upgrade
The apt update
command refreshes the package list, while apt upgrade
installs the available updates. This step helps resolve any dependency issues and provides access to the latest security patches and bug fixes.
Step 2: Installing Nginx and PostgreSQL.
Next, we will install Nginx and PostgreSQL using the following command:
sudo apt install nginx postgresql
Once the installation is complete, we need to configure PostgreSQL for Fathom Analytics. Follow these steps:
Switch to the PostgreSQL user:
sudo -u postgres psql
Create a new database and user for Fathom:
CREATE USER fathom WITH CREATEDB CREATEROLE PASSWORD 'password'; CREATE DATABASE fathomdb OWNER fathom;
Exit the PostgreSQL shell:
\q
Step 3. Installing Fathom Analytics on Ubuntu 24.04.
Now that we have the necessary prerequisites in place, let’s download and install Fathom Analytics. Visit the official Fathom Analytics GitHub repository and locate the latest release for Linux (amd64 architecture). At the time of writing, the latest version is 1.3.1. Download the release using the following command:
wget https://github.com/usefathom/fathom/releases/download/v1.3.1/fathom_1.3.1_linux_amd64.tar.gz
Once the download is complete, extract the files to the /usr/local/bin
directory:
tar -C /usr/local/bin -xzf fathom_1.3.1_linux_amd64.tar.gz
Set the execution permissions for the Fathom binary:
chmod +x /usr/local/bin/fathom
To verify that Fathom is installed correctly, run:
fathom --version
Step 4: Configure Fathom.
With Fathom installed, it’s time to configure it to work with our PostgreSQL database. Create a new configuration file:
nano /etc/fathom/config.env
Add the following lines to the file, replacing the placeholders with your PostgreSQL database details:
FATHOM_DATABASE_DRIVER=postgres FATHOM_DATABASE_NAME=fathomdb FATHOM_DATABASE_USER=fathom FATHOM_DATABASE_PASSWORD=password FATHOM_DATABASE_HOST=localhost FATHOM_DATABASE_PORT=5432
Save the file and exit the editor.
Step 5. Set Up Systemd Service for Fathom.
To ensure that Fathom Analytics starts automatically on system boot and restarts in case of any failures, we will create a systemd
service. Create a new service file:
nano /etc/systemd/system/fathom.service
Add the following content to the file:
[Unit] Description=Fathom Analytics After=network.target [Service] ExecStart=/usr/local/bin/fathom server --config /etc/fathom/config.env Restart=always [Install] WantedBy=multi-user.target
Save the file and exit the editor. Enable and start the Fathom service:
sudo systemctl enable fathom sudo systemctl start fathom
To verify that the service is running correctly, use the following command:
sudo systemctl status fathom
Step 6. Configure Nginx as a Reverse Proxy.
To access Fathom Analytics through your domain name, we will configure Nginx as a reverse proxy. Create a new virtual host file for Fathom:
sudo nano /etc/nginx/sites-available/fathom
Add the following configuration, replacing your_domain.com
with your actual domain name:
server { listen 80; server_name your_domain.com; location / { proxy_pass http://localhost:9000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
Save the file and exit the editor. Enable the configuration by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/fathom /etc/nginx/sites-enabled/
Test the Nginx configuration for any syntax errors:
sudo nginx -t
If no errors are reported, restart the Nginx service:
sudo systemctl restart nginx
Step 7. Secure the Installation with SSL.
To ensure secure communication between clients and your Fathom Analytics instance, we will obtain an SSL certificate using Certbot and Let’s Encrypt. Install Certbot and the Nginx plugin:
sudo apt install certbot python3-certbot-nginx
Obtain an SSL certificate for your domain:
sudo certbot --nginx -d your_domain.com
Follow the prompts to provide an email address and agree to the Let’s Encrypt terms of service. Certbot will automatically configure Nginx to use the obtained SSL certificate.
Step 8. Accessing the Fathom Web Interface.
With the installation and configuration complete, you can now access the Fathom Analytics web interface. Open a web browser and navigate to:
https://your_domain.com
You will be greeted with the Fathom Analytics login screen. Use the default admin credentials (admin/admin) to log in. Once logged in, you can change the admin password, create new sites to track, and customize your Fathom Analytics instance.
Congratulations! You have successfully installed Fathom. Thanks for using this tutorial for installing Fathom Analytics on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Fathom website.