This tutorial will guide you through the process of installing Plausible Analytics on the latest version of FreeBSD. Plausible Analytics is an open-source, lightweight, privacy-friendly alternative to Google Analytics that doesn't use cookies, doesn't collect personal data and is fully compliant with GDPR, CCPA and PECR regulations.
To complete this tutorial, you will need:
Plausible Analytics is packaged as a Docker container, so you'll need Docker installed on your FreeBSD instance. If you don't already have Docker installed, you can install it by running the following command:
pkg install docker
To persist data between container restarts and updates, we'll create a data directory for Plausible Analytics. Run the following command to create the directory:
mkdir -p /opt/plausible-analytics/data
We'll create a Docker network that the Plausible Analytics container will use. Run the following command to create the network:
docker network create plausible-analytics
Now we're ready to run the Plausible Analytics container. Run the following command, replacing example.com
with your domain name and PLAUSIBLE_DATA=/opt/plausible-analytics/data
with the path to your data directory:
docker run -d \
--name plausible-analytics \
--restart=always \
--network=plausible-analytics \
--env "PLAUSIBLE_HOST=https://example.com" \
--env "PLAUSIBLE_DATA=/opt/plausible-analytics/data" \
-v /opt/plausible-analytics/data:/plausible/data \
plausible/analytics:latest
This command will pull the latest version of the Plausible Analytics container and start it in the background with the following options:
--name plausible-analytics
: a name for the container.--restart=always
: restart the container automatically if it fails or is stopped.--network=plausible-analytics
: use the Docker network we created earlier.--env "PLAUSIBLE_HOST=https://example.com"
: set the domain name for the Plausible Analytics instance.--env "PLAUSIBLE_DATA=/opt/plausible-analytics/data"
: set the path to the data directory.-v /opt/plausible-analytics/data:/plausible/data
: mount the data directory as a volume inside the container.plausible/analytics:latest
: the Docker image to use.Finally, you need to configure your web server to proxy requests to the Plausible Analytics container. If you're using NGINX, you can add the following configuration to your site configuration file, replacing example.com
with your domain name:
location = /api/event {
proxy_pass http://plausible-analytics:8000;
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;
}
location = /api/ping {
proxy_pass http://plausible-analytics:8000;
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;
}
location / {
proxy_pass http://plausible-analytics:8080;
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;
}
This configuration will proxy requests to the Plausible Analytics container on ports 8000 and 8080.
Congratulations! You've successfully installed Plausible Analytics on the latest version of FreeBSD. You can now access your analytics dashboard by visiting your domain name in a web browser. If you encounter any issues, refer to the Plausible Analytics documentation or contact their support team.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!