How to Install Plausible Analytics on Void Linux

Plausible Analytics is an open-source web analytics platform that provides simple and privacy-friendly website analytics. In this tutorial, we will guide you on how to install Plausible Analytics on Void Linux.

Prerequisites

  1. A server or VPS running Void Linux
  2. A non-root user account with sudo privileges
  3. A domain name pointed to your server's IP address

Step 1: Install Dependencies

First, update your system's package list, then install the required dependencies:

sudo xbps-install -S python3 nginx certbot

Python3, NGINX and Certbot together will serve the purpose.

Step 2: Download and Install Plausible Analytics

Download the latest version of Plausible Analytics by running the following command:

wget https://github.com/plausible/analytics/releases/download/v1.4.4/plausible-1.4.4-x86_64-unknown-linux-gnu.tar.gz

Next, extract the downloaded archive using the following command:

tar -xzf plausible-1.4.4-x86_64-unknown-linux-gnu.tar.gz

Now, move the extracted directory to /opt:

sudo mv plausible /opt/plausible

Step 3: Configure NGINX

Create a new NGINX configuration file for Plausible Analytics by running the following command:

sudo nano /etc/nginx/sites-available/plausible

Add the following configuration:

server {
  listen 80;
  listen [::]:80;
  server_name your-domain.com;

  location / {
    return 301 https://$host$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;

  access_log /var/log/nginx/plausible-access.log;
  error_log /var/log/nginx/plausible-error.log;

  location / {
    proxy_pass http://127.0.0.1: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;
  }
}

Modify the following:

Step 4: Enable the NGINX configuration

Now, enable the newly created NGINX configuration for plausible:

sudo ln -s /etc/nginx/sites-available/plausible /etc/nginx/sites-enabled/

Check the NGINX configuration for any errors:

sudo nginx -t

If you see "Syntax OK," then start NGINX:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 5: Start Plausible Analytics

Change the ownership of the /opt/plausible directory to the current user:

sudo chown -R $USER:$USER /opt/plausible

Start the Plausible Analytics service:

cd /opt/plausible
./plausible start

Plausible Analytics is now running and can be accessed in a web browser at https://your-domain.com.

Step 6: Install SSL certificates

Generate a Let's Encrypt SSL certificate for your domain using Certbot:

sudo certbot --nginx -d your-domain.com -m your-email@example.com --agree-tos --no-eff-email

Follow the prompts to complete the process. After the SSL certificate is installed, restart nginx:

sudo systemctl restart nginx

Conclusion

That's it! You have successfully installed Plausible Analytics on your Void Linux server. If you have any issues or questions, you can refer to the official documentation at https://plausible.io/docs/self-hosting or seek out support from the Plausible Analytics community.

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!