DEV Community

Cover image for Deploying Plausible Analytics - Self-Hosted Web Analytics Platform
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya • Originally published at docs.vultr.com

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
Enter fullscreen mode Exit fullscreen mode

2. Generate a secret key:

$ openssl rand -base64 64 | tr -d '\n'
Enter fullscreen mode Exit fullscreen mode

3. Create the environment file:

$ nano .env
Enter fullscreen mode Exit fullscreen mode
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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
services:
  plausible:
    ports:
      - 127.0.0.1:8000:8000
Enter fullscreen mode Exit fullscreen mode

Deploy with Docker Compose

$ docker compose up -d
$ docker compose ps
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

2. Create the virtual host:

$ sudo nano /etc/nginx/sites-available/plausible.conf
Enter fullscreen mode Exit fullscreen mode
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";
    }
}
Enter fullscreen mode Exit fullscreen mode

3. Enable and test:

$ sudo ln -s /etc/nginx/sites-available/plausible.conf /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl reload nginx
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Create the Admin Account and Add a Site

  1. Open https://plausible.example.com/register.
  2. Enter your name, email, and password, then Create my account.
  3. Enter the domain you want to track, pick your reporting timezone, click Install Plausible.
  4. Copy the JavaScript tracking snippet into your site's <head>. Click Verify Script installation once it's live.
  5. 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.

Top comments (0)