Deploying Plausible Analytics - Self-Hosted Web Analytics Platform
DEV Community

Deploying Plausible Analytics - Self-Hosted Web Analytics Platform

Plausible Analytics is an open-source, self-hosted web analytics tool that tracks traffic without cookies or personal data collection, a privacy-first alternative to Google Analytics. This guide deploys Plausible Community Edition using Docker Compose, fronts it with Nginx, and secures it with a Let's Encrypt certificate. By the end, you'll have Plausible tracking a website's traffic securely at your domain.

Configure the Environment

  1. Clone the Community Edition repo:

    $ mkdir ~/plausible
    $ cd ~/plausible
    $ git clone https://github.com/plausible/community-edition.git
    $ cd community-edition
    
  2. Generate a secret key:

    $ openssl rand -base64 64 | tr -d '\n'
    
  3. Create the environment file:

    $ nano .env
    
    ADMIN_USER_EMAIL = admin@example.com
    ADMIN_USER_NAME = admin
    ADMIN_USER_PWD = ADMIN_PASSWORD
    BASE_URL = https://plausible.example.com
    SECRET_KEY_BASE = YOUR_SECRET_KEY_BASE
    DATABASE_URL = postgres://postgres:postgres@plausible_db:5432/plausible_db
    CLICKHOUSE_DATABASE_URL = http://plausible_events_db:8123/plausible_events_db
    

    Fill in your email, a strong admin password, your domain, and the secret key generated above.

  4. Expose the app port via a Compose override (auto-merged with compose.yml):

    $ nano compose.override.yaml
    
    services :
      plausible :
        ports :
          - 127.0.0.1:8000:8000
    

Deploy with Docker Compose

$ docker compose up -d
$ docker compose ps

Confirm the app, Postgres, and ClickHouse (events DB) containers are all running.

Front with Nginx and Let's Encrypt

  1. Install Nginx:

    $ sudo apt update
    $ sudo apt install nginx -y
    
  2. Create the virtual host:

    $ sudo nano /etc/nginx/sites-available/plausible.conf
    
    server {
      listen 80 ;
      listen [::]:80 ;
      server_name plausible.example.com ;
      access_log /var/log/nginx/plausible.access.log ;
      error_log /var/log/nginx/plausible.error.log ;
    
      location / {
        proxy_pass http://127.0.0.1:8000 ;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
        proxy_http_version 1.1 ;
        proxy_set_header Upgrade $http_upgrade ;
        proxy_set_header Connection "Upgrade" ;
      }
    }
    
  3. Enable and test:

    $ sudo ln -s /etc/nginx/sites-available/plausible.conf /etc/nginx/sites-enabled/
    $ sudo nginx -t
    $ sudo systemctl reload nginx
    
  4. Issue a Let's Encrypt certificate:

    $ sudo apt install certbot python3-certbot-nginx -y
    $ sudo ufw allow 80,443/tcp
    $ sudo certbot --nginx -d plausible.example.com -m admin@example.com --agree-tos --no-eff-email
    

Create the Admin Account and Add a Site

  • Open https://plausible.example.com/register.
  • Enter your name, email, and password, then Create my account.
  • Enter the domain you want to track, pick your reporting timezone, click Install Plausible.
  • Copy the JavaScript tracking snippet into your site's <head>.
  • Click Verify Script installation once it's live.
  • Refresh after the first page view registers; the dashboard opens with live traffic stats.

Next Steps

Plausible is running and served securely over HTTPS. From here you can:

  • Add more sites to track from the same dashboard
  • Set up email or Slack weekly/monthly reports under site settings
  • Enable the Stats API for custom dashboards or exporting data elsewhere

For the full guide with additional tips, visit the original article on Vultr Docs.

Comments

No comments yet. Start the discussion.