How to install Fathom Analytics on Ubuntu


Fathom is a self-hosted open-source web analytics platform that gives simple, useful website statistics without tracking or storing your users’ personal information.

It is a very good alternative to Google Analytics with a simple web interface that can be used for small and medium businesses. Fathom gives you full control over your data without using third-party solutions. Fathom offers you top pages, top referrers, bounce rate, and average time spent on your website.

Fathoms are installed based on version. This blog will be discussing how to install Fathom Analytics on a Ubuntu 20.04 cloud server running a LEMP stack and configure Nginx as a reverse proxy. This simplifies hosting multiple websites and SSL certificates on a single server.

What you need to install Fathom on Ubuntu 20.04 (Prerequisites)

  • An active domain or subdomain name pointed to your server
  • An existing Ubuntu 20.04 Vultr Server
  • SSH to the server as a regular user with sudo privileges
  • Install the LEMP Stack
  • Update the server

How to install Fathom Analytics on Ubuntu

Step 1: Create a New MySQL Database

  1. Log in to MySQL.$ mysql -u root -p
  2. Create a new Fathom database.mysql> CREATE DATABASE fathomdb;
  3. Create a new user with a strong password.mysql> CREATE USER 'fathomuser’@’localhost' IDENTIFIED BY 'STRONG-PASSWORD';
  4. Grant the user full permissions to the Fathom database.mysql> GRANT ALL PRIVILEGES ON Fathomdb.* TO 'fathomuser’@’localhost';
  5. Reload privileges and exit the console.mysql> FLUSH PRIVILEGES; mysql> EXIT

Step 2: Install Fathom Analytics

  1. Download the latest Fathom Analytics tarball from its GitHub page.$ wget
  2. Change to your home directory.$ cd ~
  3. Create the directory.$ mkdir fathom-files
  4. Extract files from the tar archive.$ tar -xvf fathom_1.2.1_linux_amd64.tar.gz -C fathom-files
  5. Change to the files directory.$ cd fathom-files
  6. Check the current Fathom version.$ sudo ./fathom --version OutputFathom version 1.2.1, commit 8f7c6d2e45ebb28651208e2a7320e29948ecdb2c, built at 2018-11-30T

Step 3: Configure Fathom Analytics

Fathom requires a database to store tables and metadata necessary for all registered websites. Database information has to be entered in a .env file. Create one inside the Fathom files directory.

  1. In your favorite editor, create and edit the file .env.$ nano /fathom-files/.env
  2. Paste the following configuration codes. This configures Fathom Analytics to run on port 8080, then connect to MySQL as the database server with your database name, username, and password you created in Step 1 of this guide.FATHOM_SERVER_ADDR=9000 FATHOM_GZIP=true FATHOM_DEBUG=true FATHOM_DATABASE_DRIVER="mysql" FATHOM_DATABASE_NAME="fathomdb" FATHOM_DATABASE_USER="fathomuser" FATHOM_DATABASE_PASSWORD="STRONG-PASSWORD" FATHOM_DATABASE_HOST="localhost" FATHOM_SECRET="random-secret-string"
  3. Save and close the file.
  4. Register the first administrator user account by running fathom with user add arguments.
  5. Replace with your actual email, then assign a strong password to make your Fathom installation as secure as possible.
INFO[0000] Fathom version 1.2.1, commit 8f7c6d2e45ebb28651208e2a7320e29948ecdb2c, built at 2018-11-30T09:21:37Z INFO[0000] Configuration file: /home/example/fathom-files/.env INFO[0000] Connected to mysql database: fathomdb on localhost INFO[0001] Applied 24 database migrations! INFO[0001] Created user

Configure Nginx to serve Fathom files on a specific subdomain, or full domain name pointed to your server. As an example, this guide uses the subdomain Replace this with your domain name.

  1. In your favorite editor, create a new Nginx virtual host configuration file (server blocks) in the /etc/nginx/sites-available/ directory.$ sudo nano /etc/nginx/sites-available/fathomweb.conf
  2. Paste the following configuration code.server { server_name; access_log /var/log/nginx/fathom.access.log; error_log /var/log/nginx/fathom.error.log; location / { proxy_pass http://localhost:9000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; } }
  3. Save and close the file.
  4. Enable the configuration file by creating a link to /etc/nginx/sites-enabled/.$ sudo ln -s /etc/nginx/sites-available/fathomweb.conf /etc/nginx/sites-enabled/
  5. Test your Nginx configuration.$ sudo nginx -t
  6. Restart Nginx.$ sudo service nginx restart
  7. Allow port 9000 on your firewall.$ sudo ufw allow 9000/tcp

Step 4: Setup Fathom Analytics as a System service

Because Fathom analytics runs as a self-hosted application, it is safe to run it as a system-wide service that starts at system boot without any manual restarts. Create a new systemd service file under /etc/systemd/system and point to both the Fathom directory and application script.

  1. In your favorite editor, create and edit the file fathom.service.$ sudo nano /etc/systemd/system/fathom.service
  2. Paste the following commands:[Unit] Description=Fathom Analytics Server [Service] Type=simple User=fathom Group=fathom Restart=always RestartSec=3 WorkingDirectory=/usr/local/bin/fathom-files ExecStart=/usr/local/bin/fathom-files/fathom server [Install]
  3. Save and close the file.
  4. The systemd service file describes that Fathom runs with user account fathom, and group fathom.
  1. Create the new user and group to avoid any potential run time errors.$ sudo adduser --system --group --home /usr/local/bin/fathom-files/ fathom A new user ‘fathom’ and group will be added to the server, and /usr/local/bin/fathom-files will be created as the home directory with no login access since a password has not been specified.
  2. Copy all Fathom files to the new home directory /usr/local/bin/fathom-files/.$ sudo mv ~/fathom-files/.* /usr/local/bin/fathom-files
  3. Grant the user fathom full ownership to the /usr/local/bin/fathom-files/ directory.$ sudo chown -R fathom:fathom /usr/local/bin/fathom-files
  4. Restart the systemd daemon.$ sudo systemctl daemon-reload
  5. Enable the Fathom service.$ sudo systemctl enable fathom
  6. Start the Fathom service.$ sudo systemctl start fathom
  7. Check the status. Make sure it’s running with no errors.$ sudo systemctl status fathom

Step 5: Test Fathom Analytics
Now that Fathom is running, visit your server in a web browser to launch the main application dashboard.

Log in with the administrator password and email created on Step 2 of this guide. Then, start using your new Fathom Analytics application.

To link websites, copy the listed Javascript code to your website’s head section to automatically add it to your dashboard.



You have successfully installed Fathom Analytics on a Ubuntu 20.04 cloud server running the LEMP Stack. You can link your existing websites without any limitations on traffic or the number of web applications you can add.

Leave a Reply

Inline Feedbacks
View all comments