Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

How to Install Fathom Analytics on Ubuntu 24.04

How to Install Fathom Analytics on Ubuntu 24.04

Implementing Fathom Analytics on your Ubuntu 24.04 server allows you to gain privacy-focused website insights without relying on third-party trackers. This guide walks you through the entire process of installing Fathom, from prerequisites to troubleshooting, ensuring you can monitor your website traffic efficiently and securely. Before starting, ensure you have a basic understanding of command-line operations, a registered domain name, and administrative access to your Ubuntu server. Additionally, you should have a working web server (such as Nginx or Apache) and a domain pointing to your server’s IP address.

What You’ll Need

  • An Ubuntu 24.04 server with root or sudo access
  • Domain name pointing to your server’s IP
  • Docker installed and running (recommended for simplicity)
  • Basic knowledge of terminal commands and server management
  • SSL certificate for secure HTTPS connection (optional but recommended)

Step-by-Step

  1. Update Your Server
    Open your terminal and run:

    sudo apt update && sudo apt upgrade -y

    This ensures your system packages are current, reducing potential conflicts during installation.

  2. Install Docker and Docker Compose
    Fathom recommends using Docker for easy deployment. Install Docker with:

    sudo apt install docker.io docker-compose -y

    Start and enable Docker:

    sudo systemctl start docker
    sudo systemctl enable docker
  3. Create a Directory for Fathom
    Set up a dedicated folder:

    mkdir -p ~/fathom
    cd ~/fathom
  4. Get the Docker Compose File
    Create a docker-compose.yml file inside this directory with the following content, replacing yourdomain.com with your actual domain:

    version: '3'
    services:
      fathom:
        image: usefathom/fathom:latest
        container_name: fathom
        environment:
          - FATHOM_DATABASE_HOST=fathom-db
          - FATHOM_DATABASE_USER=fathom
          - FATHOM_DATABASE_PASSWORD=your_secure_password
          - FATHOM_DATABASE_NAME=fathom
          - VIRTUAL_HOST=yourdomain.com
          - LETSENCRYPT_HOST=yourdomain.com
          - LETSENCRYPT_EMAIL=your-email@example.com
        ports:
          - '8080:8080'
        depends_on:
          - fathom-db
      fathom-db:
        image: postgres:13
        environment:
          - POSTGRES_DB=fathom
          - POSTGRES_USER=fathom
          - POSTGRES_PASSWORD=your_secure_password
        volumes:
          - fathom-db-data:/var/lib/postgresql/data
    volumes:
      fathom-db-data:
  5. Start Fathom with Docker Compose
    Run:

    docker-compose up -d

    This will download the images and start the containers. Verify with:

    docker ps
  6. Configure Your Domain and SSL
    If you’re using a reverse proxy like Nginx, set up your server block to proxy requests to your Fathom container. Use Certbot to obtain an SSL certificate:

    sudo apt install certbot python3-certbot-nginx -y
    sudo certbot --nginx -d yourdomain.com

    Follow prompts to complete SSL setup, ensuring your site is accessible via HTTPS.

  7. Access Fathom Dashboard
    Open your browser and navigate to https://yourdomain.com. Complete the initial setup by creating an admin account and adding your website to track.

Common Mistakes

  • Not updating server packages before starting, leading to incompatibility issues.
  • Using incorrect domain names or missing DNS records, causing connection failures.
  • Failing to configure environment variables properly in Docker Compose, which can prevent Fathom from running correctly.
  • Not securing your site with SSL, risking data interception and reducing trust.
  • Overlooking firewall settings; ensure ports 80, 443, and 8080 (or your custom port) are open.

Tips

  • Use a dedicated subdomain like analytics.yourdomain.com for better organization and SSL management.
  • Regularly update your Docker images with
    docker-compose pull

    and restart containers to get latest features and security patches.

  • Backup your database periodically, especially before major updates or configuration changes.
  • Set up automatic renewal of SSL certificates with Certbot to maintain HTTPS without manual intervention.
  • Monitor server resources; running multiple containers can impact performance on limited hardware.

Troubleshooting

If Fathom is not accessible or not tracking data correctly, consider the following steps:

  • Check Docker Containers: Run
    docker ps

    to verify that both Fathom and database containers are running. If not, check logs with

    docker logs 

    .

  • Verify DNS and Domain Settings: Ensure your domain points correctly to your server’s IP. Use
    dig yourdomain.com

    to confirm DNS resolution.

  • Inspect Logs: Look at the logs for any errors, especially database connection issues or environment variable misconfigurations.
  • Firewall Rules: Confirm that your server’s firewall allows inbound traffic on ports 80, 443, and your custom port if used.
  • SSL Certificate Issues: If HTTPS is not working, check Certbot renewal status with
    sudo certbot renew --dry-run

    .

  • Clear Browser Cache: Sometimes, cached data can prevent seeing recent changes. Clear cache or try incognito mode.

If problems persist, consult the Fathom documentation or community forums for specific error messages or issues.

Frequently Asked Questions

1. Do I need to install a web server like Nginx or Apache?

No, if you use Docker with environment variables for VIRTUAL_HOST and SSL, Fathom can run directly behind a reverse proxy or with Docker networking. However, setting up Nginx or Apache as a reverse proxy provides better control and SSL management.

2. Can I run Fathom without Docker?

Yes, but using Docker simplifies deployment and updates. Installing directly on Ubuntu involves manual setup of dependencies and database configuration.

3. How do I update Fathom to the latest version?

Run

docker-compose pull

inside your Fathom directory, then restart the containers with

docker-compose down && docker-compose up -d

.

4. Is Fathom free and open-source?

Yes, Fathom is open-source and free to use. You can also opt for the hosted version if preferred.

5. How secure is Fathom?

Using SSL certificates and proper server security practices makes Fathom a secure option for analytics. Regular updates also help patch vulnerabilities.

6. Can I track multiple websites with a single Fathom installation?

Yes, you can add multiple sites in the Fathom dashboard and generate tracking codes for each.

Related

How to Install Fathom Analytics on Ubuntu 24.04
Scroll to top