Self-Hosting Guide: Deploy Plausible Analytics with Docker
·OSSAlt Team
plausibleanalyticsself-hostingdockerguide
Self-Hosting Guide: Deploy Plausible Analytics with Docker
Plausible Analytics is a privacy-first, cookie-free Google Analytics alternative. Self-hosting costs ~$5/month on a VPS vs $9-19/month for Plausible Cloud. Here's the complete production setup.
Requirements
- VPS with 1 GB RAM minimum (2 GB recommended)
- Docker and Docker Compose
- Domain name (e.g.,
analytics.yourdomain.com) - SMTP service for email reports
Step 1: Server Setup
# Ubuntu/Debian
sudo apt update && sudo apt install -y docker.io docker-compose-plugin
# Start Docker
sudo systemctl enable docker
sudo systemctl start docker
Step 2: Clone and Configure
git clone https://github.com/plausible/community-edition.git plausible
cd plausible
# Generate secret key
openssl rand -base64 48
# Edit configuration
cp .env.example .env
nano .env
Essential .env settings:
BASE_URL=https://analytics.yourdomain.com
SECRET_KEY_BASE=your-generated-64-char-secret
TOTP_VAULT_KEY=your-generated-32-char-key
# SMTP for email reports
MAILER_EMAIL=analytics@yourdomain.com
SMTP_HOST_ADDR=smtp.resend.com
SMTP_HOST_PORT=587
SMTP_USER_NAME=resend
SMTP_USER_PWD=re_your_api_key
SMTP_HOST_SSL_ENABLED=true
# Optional: Google Search Console integration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-secret
# Optional: MaxMind GeoIP (for city-level data)
MAXMIND_LICENSE_KEY=your-key
MAXMIND_EDITION=GeoLite2-City
Step 3: Start Plausible
docker compose up -d
Plausible runs on port 8000 by default.
Step 4: Reverse Proxy (Caddy)
# Install Caddy
sudo apt install -y caddy
# /etc/caddy/Caddyfile
analytics.yourdomain.com {
reverse_proxy localhost:8000
}
sudo systemctl restart caddy
Caddy auto-provisions SSL via Let's Encrypt.
Step 5: DNS
Add an A record: analytics.yourdomain.com → your server IP
Step 6: Create Account and Add Site
- Open
https://analytics.yourdomain.com - Create your admin account
- Add your website domain
- Copy the tracking snippet
Step 7: Add Tracking Script
<script defer data-domain="yourdomain.com"
src="https://analytics.yourdomain.com/js/script.js"></script>
Enhanced tracking (optional):
<!-- Track outbound links + file downloads + tagged events -->
<script defer data-domain="yourdomain.com"
src="https://analytics.yourdomain.com/js/script.tagged-events.outbound-links.file-downloads.js">
</script>
Step 8: Production Hardening
Backups:
# Backup ClickHouse and PostgreSQL data
docker compose exec plausible_db pg_dump -U postgres plausible > backup.sql
# Or backup the Docker volumes
Updates:
cd plausible
git pull
docker compose pull
docker compose up -d
Monitoring: Add Uptime Kuma to monitor your Plausible instance.
Resource Usage
| Metric | Value |
|---|---|
| RAM | 512 MB – 1 GB |
| CPU | 1 core |
| Disk | 1-5 GB (depends on traffic) |
| VPS cost | $5-10/month |
Recommended VPS Providers
| Provider | Spec | Price |
|---|---|---|
| Hetzner | 2 vCPU, 2 GB RAM | €4.50/month |
| DigitalOcean | 1 vCPU, 1 GB RAM | $6/month |
| Linode | 1 vCPU, 1 GB RAM | $5/month |
| Vultr | 1 vCPU, 1 GB RAM | $5/month |
Compare analytics tools on OSSAlt — privacy, features, and self-hosting options side by side.