Why Self-Host Your Analytics?
Self-hosting Plausible Analytics means your visitor data never touches a third-party server. You get full GDPR compliance, zero data sharing, and no ongoing SaaS subscription costs — just the cost of a VPS, which can be as low as a few dollars per month.
This guide assumes basic comfort with a Linux terminal. You don't need to be a DevOps engineer.
What You'll Need
- A VPS running Ubuntu 22.04 (DigitalOcean, Hetzner, Vultr, or similar)
- A domain name pointed to your server's IP address
- Docker and Docker Compose installed
- An SMTP email service (for account emails — Mailgun free tier works)
Step 1: Prepare Your Server
SSH into your VPS and run a quick system update:
sudo apt update && sudo apt upgrade -y
Then install Docker and Docker Compose if not already present:
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
Log out and back in for the group change to take effect.
Step 2: Clone the Plausible Hosting Repository
Plausible maintains an official self-hosting repository with a pre-configured Docker Compose setup:
git clone https://github.com/plausible/hosting
cd hosting
Step 3: Configure Your Environment
Inside the hosting directory, copy the example environment file:
cp plausible-conf.env.example plausible-conf.env
Open plausible-conf.env and fill in the key values:
- BASE_URL: Your domain (e.g.,
https://analytics.yourdomain.com) - SECRET_KEY_BASE: Generate with
openssl rand -base64 64 - TOTP_VAULT_KEY: Generate with
openssl rand -base64 32 - MAILER_EMAIL / SMTP settings: Your transactional email credentials
Step 4: Start Plausible
Launch the full stack with Docker Compose:
docker compose up -d
This starts Plausible, its PostgreSQL database, and Clickhouse (for analytics storage) as background services.
Step 5: Set Up a Reverse Proxy with Nginx
You'll want Nginx to handle SSL termination. Install it and Certbot:
sudo apt install nginx certbot python3-certbot-nginx -y
Create a new Nginx site config at /etc/nginx/sites-available/plausible pointing to localhost:8000, then run:
sudo certbot --nginx -d analytics.yourdomain.com
Certbot will automatically configure HTTPS with a free Let's Encrypt certificate.
Step 6: Add the Tracking Script to Your Website
Once your instance is live, log into your Plausible dashboard, add your site, and paste the provided tracking snippet into your website's <head> tag:
<script defer data-domain="yourdomain.com" src="https://analytics.yourdomain.com/js/script.js"></script>
Keeping It Updated
To update Plausible to the latest version, pull the new images and restart:
docker compose pull
docker compose up -d
Backup Strategy
- Back up the PostgreSQL database using
pg_dumpon a scheduled cron job. - Back up the Clickhouse data directory periodically.
- Store backups offsite (e.g., S3-compatible storage like Backblaze B2).
You're Done
You now have a fully operational, privacy-respecting analytics platform that you control completely. Visit your dashboard, verify data is flowing in, and enjoy analytics without the surveillance baggage.