How to Install Plausible on a VPS with Docker: Cookie-Free Web Analytics
You know people read your blog, but you cannot say which posts actually get opened. Google Analytics answers that, at the cost of a heavy tracking script, a cookie consent banner, and visitor data landing on someone else's servers. Plausible takes a cleaner middle path: a single-page dashboard, no cookies, and data that stays on your own machine.
This guide installs Plausible Community Edition (CE) on a VPS with Docker Compose, using the project's own official Compose files. By the end you will have an analytics dashboard on your own subdomain, a tracking snippet on your site, and one goal that measures what visitors do, not just what they open.
What you need before starting
- A VPS with Docker and Docker Compose v2 installed.
- A subdomain for analytics, for example
analytics.example.com, with a DNS A record already pointing at the VPS IP. Plausible's automatic TLS certificates only work when the domain resolves to this server. - A CPU with SSE 4.2 or NEON support, which ClickHouse requires. Check with this command — if it prints
sse4_2, you are fine:
grep -o sse4_2 /proc/cpuinfo | head -1- At least 2 GB of RAM. Plausible CE runs three services at once — the Plausible app, PostgreSQL for accounts and site settings, and ClickHouse for event storage — so a 1 GB VPS will run out of memory quickly.
- Free ports
80and443, because this official install path lets Plausible issue its own Let's Encrypt certificates.
Check Docker and Compose:
docker --version
docker compose versionExpected result: both commands print a version number with no error.
Step 1: clone the official Compose repository
Plausible CE is not installed from a hand-written Compose file. The project ships a plausible/community-edition repository containing the compose.yml plus ClickHouse configuration matched to the app version. Clone a specific release tag, not the main branch, so the app and its configuration never drift apart:
git clone -b v3.2.1 --single-branch https://github.com/plausible/community-edition plausible-ce
cd plausible-ce
ls -1Expected result: the folder contains clickhouse/, compose.yml, LICENSE, and README.md. Tag v3.2.1 is the release listed in the repository when this guide was written; if you are reading this much later, check the repository's releases page for the newest tag and adjust.
Step 2: create .env with the two required variables
Only two variables are mandatory. BASE_URL is the public address where Plausible lives — use your real domain, not the example. SECRET_KEY_BASE is a random key for sessions and encrypted data; generate it with openssl and never change it after the install is running, or old sessions and encrypted data may break:
touch .env
echo "BASE_URL=https://analytics.example.com" >> .env
echo "SECRET_KEY_BASE=$(openssl rand -base64 48)" >> .env
cat .envExpected result: .env holds two lines, BASE_URL pointing at your domain and SECRET_KEY_BASE a long random string (at least 64 bytes, per the official README).
If you only want a local trial first, the official README suggests BASE_URL=http://localhost:8000. For a production VPS, stick with https:// and your own domain.
Step 3: expose Plausible to the web with an override file
Out of the box, the official compose.yml exposes no ports to the host. Add two port variables to .env and a compose.override.yml so Plausible listens on ports 80 and 443 and handles TLS automatically:
echo "HTTP_PORT=80" >> .env
echo "HTTPS_PORT=443" >> .env
cat > compose.override.yml << EOF
services:
plausible:
ports:
- 80:80
- 443:443
EOFIf you already run Nginx on the same server, skip this override — ports 80 and 443 are taken. Instead, bind Plausible to localhost only, for example 127.0.0.1:8000:80, and point your reverse proxy at http://127.0.0.1:8000. That host:80 mapping pattern follows the official README's local-evaluation example, with host and port adjusted.
Step 4: start the stack and create the first user
Bring the whole stack up in the background, then check its state:
docker compose up -d
docker compose ps
docker compose logs -f plausibleExpected result: all three containers — app, PostgreSQL, and ClickHouse — show as running, and the Plausible log shows the app ready to serve. Press Ctrl+C to leave the log view; the containers keep running.
Open https://analytics.example.com in a browser. On the first visit, Plausible asks you to create the first user account. Use a strong password — this account controls your analytics instance. After that you land on an empty dashboard, which is normal: no site is tracked yet.
Step 5: add your site and install the tracking snippet
In the dashboard, add the site you want to track using its domain, for example your-site.com. Plausible then shows a snippet for that site. Copy the snippet exactly as shown in your dashboard — it looks like this, with the host pointing at your own instance:
<script defer data-domain="your-site.com" src="https://analytics.example.com/js/script.js"></script>Paste it inside the <head> of every page on your site. If your site uses a theme or template, pasting once in the header template is enough. The defer attribute keeps the script from blocking page rendering, and data-domain tells Plausible which site is reporting.
Expected result: visit one page of your site, wait a few seconds, then reload the Plausible dashboard. That first visit — yours — shows up as one visit. If nothing appears, open the browser DevTools Network tab and look for a request to /api/event on your analytics host; no request means the script is not on that page yet.
Step 6: measure actions with goals, not just pageviews
Pageviews tell you which pages get opened. Goals tell you whether visitors do what you wanted. The two goal types you will use most are pageview goals for visits to a specific URL (like /thank-you after a form is submitted) and custom event goals for clicks and other actions.
For a custom event without writing JavaScript, add a class to the element you want to track, in this format:
<button class="plausible-event-name=Button+Click">Try Free</button>The + is read as a space, so this event appears as Button Click in the dashboard. Then create the matching goal: open your site settings, go to Goals, click Add goal, pick the Custom event trigger, and enter exactly the same name — Button Click, not Button+Click. Until the goal exists, incoming events do not show in the dashboard, and a goal only counts events that happen after it was created, never older ones.
Sensible first goals for a blog or landing page: visits to a thank-you page, clicks on a signup button, and clicks on outbound links to a registration page. Those three are enough to separate posts that are merely popular from posts that actually move readers.
Plausible or Umami: which one fits
Both are cookie-free and self-hosted, but they have different characters. Umami runs a lighter stack with a very simple dashboard — right when all you want is which pages were opened and where visitors came from. Plausible charges extra for its setup (ClickHouse and more RAM) in exchange for deeper goals, funnels, and reports. If your question stops at "how many visitors and which pages", Umami saves resources. If you want to measure conversions — which button got clicked, which form got submitted — Plausible earns its weight.
Common errors and how to fix them
| Symptom | Likely cause | Fix |
|---|---|---|
| Containers fail to start or stop right away | Ports 80/443 already in use, or CPU lacks SSE 4.2 | Free the ports or use the reverse-proxy path, check grep -o sse4_2 /proc/cpuinfo, then read docker compose logs plausible |
| Browser cannot open the domain, or certificates fail | BASE_URL does not match the domain you open, or DNS does not point at the VPS | Make BASE_URL match the real access domain, confirm the A record points at the VPS IP, then run docker compose up -d again |
| Dashboard opens but records no visits | Snippet missing from the page, or data-domain does not match the registered site domain | Check the page source, match data-domain to the dashboard domain, and look for the /api/event request in the Network tab |
| Events arrive but the goal stays at zero | Goal not created yet, or goal name does not exactly match the event name | Create the goal after events are flowing, match the name character for character (spaces, not +), then trigger the event once more |
| Instance slow or containers restarting on their own | Under 2 GB of RAM, so ClickHouse hits out-of-memory kills | Increase VPS RAM, or move other heavy services off the same server |
Maintenance: backups and updates
All installation state lives in the Docker volumes created by the official compose.yml, so the files that matter most for backup are your configuration: .env (holding the SECRET_KEY_BASE that must never change) and compose.override.yml. Keep copies somewhere safe off the VPS. For the analytics data itself, schedule regular VPS snapshots or Docker volume backups — configuration files alone are not enough.
To update, check the newest release tag in the plausible/community-edition repository, switch to it, and bring the stack up again:
cd plausible-ce
git fetch --tags
git checkout v3.2.1
docker compose pull
docker compose up -d
docker compose psReplace v3.2.1 with your target tag, and read the release notes first if anything affects configuration. Back up before updating, since database upgrades cannot always be rolled back.
The diagram above sums up the flow: a visitor opens your site, a lightweight script sends one anonymous event to your Plausible instance on your VPS, and the dashboard shows visits and goals with no cookies and no third party involved.
Summary
| Part | Value used |
|---|---|
| Install source | Official plausible/community-edition clone, tag v3.2.1 |
| Services | Plausible app, PostgreSQL, ClickHouse |
| Required .env variables | BASE_URL, SECRET_KEY_BASE |
| Public ports | 80 and 443 via compose.override.yml (or 127.0.0.1:8000:80 behind a reverse proxy) |
| CPU/RAM requirements | SSE 4.2 or NEON, at least 2 GB RAM |
| Tracking snippet | Snippet from the dashboard, data-domain = tracked site domain |
| Goals | Pageview goals and custom event goals via the plausible-event-name= class |
| Key backups | .env and compose.override.yml, plus snapshots/volume backups |
Final checklist
- All three Plausible containers show as running in docker compose ps.
- First user account created through your BASE_URL.
- One site registered and the tracking snippet installed in <head>.
- One visit recorded in the dashboard after you opened your own site.
- One goal created and triggered (pageview or custom event).
- Copies of .env and compose.override.yml stored off the VPS.
Which question do you want analytics to answer first for your site — which posts get read the most, or which button gets clicked the most? Share it in the comments, because the answer decides which first goal is worth setting up.
Read also: the companion guide in this batch is available at the Plane guide for self-hosted project management on a VPS, and the Rnevio article "How to Install Umami on a VPS: Cookie-Free Self-Hosted Web Analytics" covers a lighter analytics alternative if Plausible feels too heavy for your VPS.


Diskusi
Ada pertanyaan atau pengalaman yang ingin dibagikan?
Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.
Tulis komentar