How to Install Plausible Analytics on Manjaro
Introduction
Plausible Analytics is a lightweight, privacy-focused alternative to Google Analytics. In this tutorial, we will guide you through the installation process of Plausible Analytics on Manjaro.
Prerequisites
Before proceeding with the installation of Plausible Analytics, ensure you have the following in place:
- A Manjaro machine with root access
- A custom domain and the ability to create DNS records
Step 1: Create a System User
Create a system user for Plausible Analytics to run under. This user will have limited privileges to ensure the security of your server.
sudo useradd -r -s /bin/false plausible
Step 2: Install Dependencies
Install the required dependencies for Plausible Analytics using the following command:
sudo pacman -S nodejs npm git
Step 3: Clone the Plausible Analytics Repository
Clone the Plausible Analytics repository to your server using the following command:
sudo git clone https://github.com/plausible/analytics.git /var/www/analytics
Step 4: Configure Plausible Analytics
Navigate to the /var/www/analytics directory and create a copy of the sample configuration file:
cd /var/www/analytics
sudo cp .env.sample .env
Open the .env file in your preferred text editor:
sudo nano .env
Replace the placeholders REPLACE_ME with your desired configuration settings, such as your website URL and a random secret key for the SECRET_KEY.
NODE_ENV=production
DOMAIN=https://example.com
PUBLIC_URL=https://example.com
SECRET_KEY=REPLACE_ME
Save and close the file when done.
Step 5: Install Plausible Analytics
Install Plausible Analytics by running the following command:
sudo npm install --production
Step 6: Start Plausible Analytics
Start Plausible Analytics using the following command:
sudo npm start
Plausible Analytics should now be accessible at https://example.com.
Step 7: Set up HTTPS
To enable HTTPS on your Plausible Analytics installation, you'll need to acquire an SSL/TLS certificate for your domain. You can use Let's Encrypt for this purpose.
Once you have obtained an SSL/TLS certificate, update the DOMAIN and PUBLIC_URL values in your .env file to use https://.
Then, update your DNS records to point your domain to your server's IP address.
Conclusion
Now that you have successfully installed Plausible Analytics on Manjaro, you can start tracking your website's analytics with a privacy-focused and lightweight solution.