Plausible Analytics is a lightweight, open-source web analytics tool that measures page views and referrers without cookies or personal data. In this tutorial you will deploy Plausible Community Edition (CE), which bundles Plausible, PostgreSQL and ClickHouse in one Docker Compose project, on Ubuntu 24.04. You will put it behind Nginx with a Let's Encrypt certificate, create your admin account, and add the tracking script to a website.
Prerequisites
To follow this guide you need:
- A server running Ubuntu 24.04 LTS with at least 2 GB of RAM and 20 GB of free disk, for example a CubePath VPS. ClickHouse needs a CPU with SSE 4.2 support, which every current x86_64 server has.
- A non-root user with
sudoprivileges. - A domain name for the dashboard, referred to as
your_domain(for exampleplausible.example.com), with a DNS A record pointing toyour_server_ip. - Git, which is installed by default on Ubuntu 24.04.
Step 1 - Installing Docker Engine and Docker Compose
Plausible CE is distributed as a Compose project, so install Docker Engine and the Compose plugin from Docker's official repository. Add the repository key first:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Add the repository and install the packages:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify the installation:
sudo docker compose version
Docker Compose version v2.x.x
Step 2 - Downloading Plausible Community Edition
The Plausible team publishes the Compose files in the plausible/community-edition repository, tagged per release. Open the releases page and note the latest tag. This guide uses v3.0.1 as the example; replace it with the current tag:
cd /opt
sudo git clone -b v3.0.1 --single-branch https://github.com/plausible/community-edition plausible-ce
cd /opt/plausible-ce
The repository's compose.yml defines three services: plausible (the web app), plausible_db (PostgreSQL) and plausible_events_db (ClickHouse, which stores the events). Don't edit it; put your changes in .env and compose.override.yml so upgrades stay a simple git checkout.
Step 3 - Configuring the environment
Create the .env file with the public URL and a random secret used to sign sessions:
sudo touch .env
sudo chmod 600 .env
echo "BASE_URL=https://your_domain" | sudo tee -a .env
echo "SECRET_KEY_BASE=$(openssl rand -base64 48)" | sudo tee -a .env
echo "HTTP_PORT=8000" | sudo tee -a .env
BASE_URL must be the exact public address with https://. HTTP_PORT=8000 makes Plausible listen on plain HTTP port 8000 inside the container, because Nginx will terminate TLS.
Now publish that port on the loopback interface only. Create an override file:
sudo nano /opt/plausible-ce/compose.override.yml
services:
plausible:
ports:
- 127.0.0.1:8000:8000
Docker publishes ports by writing its own iptables rules, which bypass UFW. Binding to 127.0.0.1 keeps Plausible reachable only through Nginx.
Step 4 - Starting Plausible
Start the stack in the background:
sudo docker compose up -d
The first start pulls the images, creates both databases and runs the migrations. Check the services:
sudo docker compose ps
All three services should show Up, with the databases reporting (healthy). Confirm the web app answers locally:
curl -I http://127.0.0.1:8000
An HTTP/1.1 200 or a 302 redirect to the login page means Plausible is running. If the command fails, read the logs with sudo docker compose logs plausible.
Step 5 - Configuring Nginx and HTTPS
Install Nginx and open the firewall for SSH, HTTP and HTTPS:
sudo apt install nginx
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
Create a server block:
sudo nano /etc/nginx/sites-available/plausible
server {
listen 80;
listen [::]:80;
server_name your_domain;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
The X-Forwarded-For header matters: Plausible derives the visitor's country and its daily unique-visitor hash from the client IP, so without it every visit would appear to come from the server itself. The Upgrade headers support the live dashboard's WebSocket connection.
Enable the site and reload Nginx:
sudo ln -s /etc/nginx/sites-available/plausible /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Request a certificate. Certbot edits the server block to add TLS and an HTTP to HTTPS redirect:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your_domain
Check that automatic renewal works:
sudo certbot renew --dry-run
Step 6 - Creating your account and adding a site
Open https://your_domain/register and create the first account with your name, email and a strong password. This account owns the instance.
Once you are in, close registration so nobody else can sign up on your server. Add the setting to .env and recreate the container:
cd /opt/plausible-ce
echo "DISABLE_REGISTRATION=invite_only" | sudo tee -a .env
sudo docker compose up -d
With invite_only, new users can only join through an invitation you send from a site's settings.
Back in the dashboard, click Add a website, enter the domain you want to track (for example example.com, without https://), and pick its time zone. Plausible then shows the tracking snippet.
Step 7 - Adding the tracking script
Copy the snippet exactly as the dashboard shows it into the <head> of every page of the tracked site. For a site called example.com it looks like this:
<script defer data-domain="example.com" src="https://your_domain/js/script.js"></script>
Visit the tracked site in a browser without an ad blocker, then open its dashboard in Plausible. The visit appears in the Current visitors counter within a few seconds. You can also use the Verify installation button that Plausible shows for sites without data.
To count custom events such as sign-ups, use the script variant with tagged events or call plausible('Signup') from your JavaScript, and create a goal with the same name under Site settings > Goals.
Step 8 - Configuring email (optional)
Plausible sends invitations, password resets and weekly reports by email. To use your own SMTP server, append these variables to .env with your provider's values:
[email protected]
SMTP_HOST_ADDR=smtp.example.com
SMTP_HOST_PORT=587
SMTP_USER_NAME=your_smtp_user
SMTP_USER_PWD=your_smtp_password
Apply the change with sudo docker compose up -d.
Step 9 - Backing up and upgrading
Plausible stores accounts and site settings in PostgreSQL and all analytics events in ClickHouse, each in its own Docker volume. The simplest consistent backup stops the stack briefly and archives the volumes:
cd /opt/plausible-ce
sudo docker compose stop
sudo mkdir -p /var/backups/plausible
for v in db-data event-data; do
sudo docker run --rm -v "plausible-ce_${v}:/data:ro" -v /var/backups/plausible:/backup \
alpine tar -czf "/backup/${v}-$(date +%F).tar.gz" -C /data .
done
sudo docker compose start
Compose names the volumes after the project directory, so they are plausible-ce_db-data and plausible-ce_event-data; confirm with sudo docker volume ls. Copy the archives off the server, or take a VPS snapshot as an alternative.
To upgrade, back up first, read the release notes (major versions can include manual migration steps), then check out the new tag and recreate the containers:
cd /opt/plausible-ce
sudo git fetch --tags
sudo git checkout vX.Y.Z
sudo docker compose up -d
Troubleshooting
- All visitors show the same country or the unique count is wrong: Nginx is not sending
X-Forwarded-For, or another proxy in front of the server (a CDN) is not forwarding the client IP. - The ClickHouse container keeps restarting: the server is short on memory. Check
sudo docker compose logs plausible_events_dband give the server at least 2 GB of RAM. - Pageviews never arrive: open the browser developer tools on the tracked site and check that the request to
https://your_domain/api/eventreturns202. Ad blockers often block analytics scripts, so test in a clean browser profile.
Conclusion
Plausible Community Edition is now running on Ubuntu 24.04 behind Nginx with HTTPS, with registration closed and a site reporting data. Next, configure goals and custom events for the actions you care about, set up weekly email reports once SMTP works, and schedule the volume backup so it runs regularly.
