Self-hosting Plausible Analytics on a $5 Ubuntu VPS provides complete control over your website data, ensuring privacy and compliance with data regulations like GDPR, CCPA, and PECR. This tutorial outlines a step-by-step process using Docker, Nginx, and Let's Encrypt to deploy Plausible Analytics version 1.9.0 (as of 2026-04) on a minimal virtual private server, making it a cost-effective and privacy-focused alternative to commercial analytics platforms.
Prerequisites and Initial Server Setup
Before deploying Plausible Analytics, you need a virtual private server running Ubuntu 24.04 LTS. Many VPS providers offer suitable plans for around $5 per month, providing enough resources for Plausible to handle a substantial amount of traffic. For those seeking reliable infrastructure, considering a managed VPS provider like Valebyte can offer peace of mind, even for a $5 tier equivalent, as of 2026-04.
You also require a registered domain name with its DNS A record pointed to your VPS's public IP address. This is crucial for Nginx to serve your analytics dashboard and for Let's Encrypt to issue an SSL certificate. For optimal security, ensure your server is hardened with a firewall (UFW) and SSH key authentication. Refer to Nelsa's Ubuntu 24.04 VPS Hardening Checklist for Initial Server Setup for a detailed guide.
- Update Your System: Begin by updating your server's package list and upgrading existing packages to their latest versions.
- Install Essential Packages: Some basic tools are necessary for the setup.
- Configure UFW Firewall: Allow SSH, HTTP, and HTTPS traffic.
- Set Hostname: Configure your server's hostname to match your domain.
sudo apt update && sudo apt upgrade -y sudo apt install -y curl wget git nano ufw sudo ufw allow OpenSSHsudo ufw allow http sudo ufw allow httpssudo ufw enable sudo hostnamectl set-hostname your_domain.comInstalling Docker and Docker Compose
Plausible Analytics leverages Docker for containerization, simplifying deployment and ensuring environment consistency. Docker Engine 25.0 (released February 2025) and Docker Compose are the core components needed for this setup.
First, remove any older versions of Docker that might be present on your system to avoid conflicts. Then, install the necessary dependencies for Docker's repository.
for pkg in docker.io docker-doc docker-compose docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin golang-docker-credential-helpers; do sudo apt remove $pkg; done sudo apt install -y ca-certificates curl gnupgNext, add Docker's official GPG key and set up the repository. This ensures that you receive genuine Docker packages directly from the source.
sudo install -m 0755 -d /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgsudo chmod a+r /etc/apt/keyrings/docker.gpecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt updateWith the repository configured, you can now install Docker Engine, containerd, and Docker Compose. These packages will enable you to run and manage Plausible's containers efficiently. As of 2026-04, Docker Engine 25.0 is a stable and widely used version, offering robust container management features.
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginVerify that Docker is running correctly by executing a test command. The output should confirm that the Docker daemon is active and accessible.
sudo systemctl status dockerFor security best practices, always run Docker commands as a non-root user by adding your user to thedockergroup:sudo usermod -aG docker $USER && newgrp docker.
For more detailed information on Docker installation and best practices, consult the official Docker Engine installation guide for Ubuntu.
Setting Up Plausible Analytics
This section guides you through configuring Plausible Analytics using Docker Compose. The setup involves creating a dedicated directory, defining the services in a docker-compose.yml file, and securing your instance with a unique secret key.
Create Plausible Project Directory and Configuration
Start by creating a directory for your Plausible project. This centralizes all your configuration files and data volumes.
mkdir -p ~/plausiblecd ~/plausiblePlausible requires a unique SECRET_KEY_BASE for cryptographic operations. Generate a strong key using the following command:
openssl rand -base64 64Copy the generated key. You will use this in the next step. It's critical to keep this key secure and not share it publicly.
Now, create a plausible-conf.env file to store environment variables specific to your Plausible instance. This file helps manage configurations without hardcoding them into the docker-compose.yml.
nano plausible-conf.envAdd the following content to plausible-conf.env, replacing YOUR_SECRET_KEY_BASE with the key you generated, and your_domain.com with your actual domain:
BASE_URL=https://your_domain.comSECRET_KEY_BASE=YOUR_SECRET_KEY_BASEDISABLE_REGISTRATION=falseEMAIL_FROM=plausible@your_domain.com# For email setup, uncomment and configure these:# SMTP_HOST=smtp.mailgun.org# SMTP_PORT=587# SMTP_USER=postmaster@your_domain.com# SMTP_PASS=your_smtp_password# SMTP_AUTH_METHOD=plain# SMTP_ADAPTER=Smtp# For ClickHouse configuration, which is default:# DATABASE_URL=postgresql://plausible:plausible@postgresql/plausible# CLICKHOUSE_DATABASE_URL=http://clickhouse:8123If you prefer to disable user registration after your initial setup, change DISABLE_REGISTRATION=false to DISABLE_REGISTRATION=true.
Create the Docker Compose File
The docker-compose.yml file orchestrates the Plausible Analytics services, including the web application, PostgreSQL database, and ClickHouse database. Create this file in your ~/plausible directory:
nano docker-compose.ymlPaste the following content. This configuration uses the latest stable Plausible image, PostgreSQL 14.x (as of 2026-04), and ClickHouse for efficient data storage and querying.
version: "3.9"services: plausible: image: plausible/analytics:latest restart: always ports: - 8000:8000 env_file: - plausible-conf.env volumes: - plausible_db:/home/plausible/db depends_on: - postgresql - clickhouse command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh start" postgresql: image: postgres:14-alpine restart: always environment: POSTGRES_DB: plausible POSTGRES_USER: plausible POSTGRES_PASSWORD: plausible volumes: - postgresql_db:/var/lib/postgresql/data clickhouse: image: clickhouse/clickhouse-server:latest restart: always ulimits: nofile: soft: 262144 hard: 262144 volumes: - clickhouse_db:/var/lib/clickhouse - ./clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.xml - ./clickhouse/users.xml:/etc/clickhouse-server/users.xmlvolumes: plausible_db: postgresql_db: clickhouse_db:You also need to create the ClickHouse configuration files. These files define how ClickHouse operates and handles user access. Create the directory and files:
mkdir -p clickhousenano clickhouse/clickhouse-config.xmlAdd the following basic configuration for ClickHouse:
information true :: 0.0.0.0 1024 3 0 nano clickhouse/users.xmlAdd a basic users configuration. For a production environment, you might want to strengthen these credentials:
::/0 default default Start Plausible Analytics
Now, run Docker Compose to pull the images and start all the services. The -d flag runs the containers in detached mode, allowing them to operate in the background.
sudo docker compose up -dThis command initiates the download of Docker images and starts the PostgreSQL, ClickHouse, and Plausible Analytics containers. You can verify their status using sudo docker compose ps. After a few moments, all services should show as Up.
At this point, Plausible is running internally on port 8000. You won't be able to access it directly via your domain yet, as Nginx needs to be configured as a reverse proxy.
Configuring Nginx as a Reverse Proxy
Nginx 1.27 (released August 2024) acts as a high-performance reverse proxy, forwarding web traffic from your domain to the Plausible Docker container. It also handles SSL termination, caching, and serving static assets efficiently. If you're considering alternatives, Nelsa has a useful Nginx vs Caddy on a Small VPS: A 2026 Benchmark Comparison.
Install Nginx
Install Nginx from the Ubuntu repositories. This provides a stable and secure version of the web server.
sudo apt install -y nginxAfter installation, Nginx typically starts automatically. Verify its status:
sudo systemctl status nginxCreate Nginx Configuration for Plausible
Create a new Nginx server block configuration file for your Plausible domain. This file will define how Nginx handles requests for your analytics instance.
sudo nano /etc/nginx/sites-available/plausible.confAdd the following configuration, replacing your_domain.com with your actual domain. This setup directs HTTP traffic to HTTPS and proxies all requests to the Plausible container running on port 8000.
server { listen 80; listen [::]:80; server_name your_domain.com; return 301 https://your_domain.com$request_uri;}server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name your_domain.com; ssl_certificate /etc/letsencrypt/live/your_domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your_domain.com/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/your_domain.com/chain.pem; include /etc/nginx/snippets/ssl-params.conf; # Will create this below location / { proxy_pass http://localhost:8000; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_redirect off; proxy_buffering off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }}Create the SSL parameters snippet file for Nginx to ensure strong TLS settings. This improves security and performance.
sudo nano /etc/nginx/snippets/ssl-params.confAdd these recommended SSL configurations:
ssl_protocols TLSv1.2 TLSv1.3;ssl_prefer_server_ciphers on;ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;ssl_ecdh_curve secp384r1;ssl_session_cache shared:SSL:10m;ssl_session_timeout 10m;ssl_session_tickets off;ssl_stapling on;ssl_stapling_verify on;resolver 8.8.8.8 8.8.4.4 valid=300s;resolver_timeout 5s;add_header X-Frame-Options DENY;add_header X-Content-Type-Options nosniff;add_header X-XSS-Protection "1; mode=block";Enable Site and Test Nginx
Enable the new Nginx configuration by creating a symlink to sites-enabled and remove the default Nginx configuration.
sudo ln -s /etc/nginx/sites-available/plausible.conf /etc/nginx/sites-enabled/sudo rm /etc/nginx/sites-enabled/defaultTest your Nginx configuration for any syntax errors before restarting the service. This prevents potential downtime caused by misconfigurations.
sudo nginx -tIf the test is successful, restart Nginx to apply the changes.
sudo systemctl restart nginxAt this stage, Nginx is configured, but you'll encounter a certificate error if you try to access https://your_domain.com because we haven't obtained an SSL certificate yet. The HTTP redirect to HTTPS is active, but HTTPS itself isn't fully set up without the certificate files.
Securing with Let's Encrypt SSL
Using Let's Encrypt provides free, automated SSL/TLS certificates, encrypting communication between your users and your Plausible Analytics instance. Certbot automates the process of obtaining and renewing these certificates.
Install Certbot and Obtain Certificate
Install Certbot and the Nginx plugin. This allows Certbot to automatically configure Nginx for SSL.
sudo apt install -y certbot python3-certbot-nginxRun Certbot to obtain your SSL certificate. Replace your_domain.com with your actual domain and [email protected] with your email address.
sudo certbot --nginx -d your_domain.com -m [email protected] --agree-tos --no-eff-emailCertbot will interactively guide you through the process, automatically modifying your Nginx configuration to include the SSL certificate paths. If you encounter issues like rate limits, Nelsa's guide on Fixing Let's Encrypt Rate Limit Reached Errors in 2026 can provide assistance.
Automate Certificate Renewal
Let's Encrypt certificates are valid for 90 days. Certbot includes a cron job or systemd timer to automate renewal. You can test the renewal process without actually renewing:
sudo certbot renew --dry-runIf the dry run is successful, your certificates will automatically renew before they expire. This ensures continuous secure access to your Plausible instance.
For more details on Certbot and Let's Encrypt, refer to the official Certbot documentation.
Post-Installation and Maintenance
After successfully deploying Plausible Analytics, there are a few essential steps to complete your setup and ensure long-term stability and security.
Create Your First Plausible User
Navigate to your domain in a web browser (https://your_domain.com). You should see the Plausible Analytics login/registration page. Create your first user account by entering your email and choosing a strong password. This account will be the administrator for your Plausible instance.
Once logged in, you can add your website and start collecting analytics data. Plausible's interface is designed for simplicity, providing clear insights into your website traffic without overwhelming dashboards.
Updating Plausible Analytics
Keeping Plausible updated is crucial for security and access to new features. Since you're using Docker Compose, updating is straightforward:
cd ~/plausible sudo docker compose pull sudo docker compose up -dThese commands pull the latest Plausible images and restart your containers, applying any updates. Plausible Analytics version 1.9.0 (as of 2026-04) includes various performance improvements and new reporting features, making regular updates beneficial.
Backup Strategy
Regular backups of your Plausible data are vital. The data volumes for PostgreSQL and ClickHouse contain all your analytics information. You can use tools like rsync or restic to back up these Docker volumes to an offsite location.
A simple backup process involves stopping Plausible, backing up the volumes, and then restarting. For example, to back up PostgreSQL data:
cd ~/plausible sudo docker compose stop plausible postgresql sudo tar -cvf plausible_pg_backup_$(date +%F).tar postgresql_db sudo docker compose start plausible postgresqlFor ClickHouse, a similar approach can be taken. Always ensure backups are tested to confirm data integrity. The official Plausible documentation on backups provides more advanced strategies.
Advantages of Self-Hosting Plausible
Self-hosting Plausible Analytics on your own VPS offers several compelling advantages, especially for organizations prioritizing data privacy and control. Firstly, it ensures that all your website's analytics data resides on your server, not a third-party's. This eliminates concerns about data being used for purposes other than your own analysis, a common issue with larger analytics providers.
Secondly, deploying Plausible on a $5 Ubuntu VPS provides significant cost savings compared to many commercial analytics solutions, particularly as your traffic scales. You pay for the VPS resources, not a per-pageview fee. Finally, you retain full control over updates, configurations, and data retention policies, allowing for a highly customized and compliant analytics environment.
By following this tutorial, you've established a robust, privacy-friendly analytics solution that puts you in charge of your data. This setup is not only economical but also aligns with the growing demand for ethical data practices.





