Setting up Umami (Google Analytics Alternative)
Umami is a simple, fast, privacy-focused alternative to Google Analytics.
I am writing this for myself for future reference: In this tutorial, I’ll be setting up Umami with PostegreSQL.
Installing Node.js
Begin by installing Node.js 16.13 or newer
here: https://github.com/nodesource/distributions#installation-instructions
Install PostegreSQL
1apt install postgresql
More info here: https://www.postgresql.org/download/linux/debian/
Preparing the database
1su -c "psql" - postgres
2
3CREATE ROLE umami WITH LOGIN PASSWORD 'yourpassword';
4CREATE DATABASE umami WITH OWNER umami;
Now exit from this shell with ^C
.
Creating an user for node
1adduser --gecos "" --disabled-password node
Install Yarn
1npm install -g yarn
Install PM2 globally to daemonize node
1npm install -g pm2
Get the source code and install packages
1cd /var/www/
2git clone https://github.com/umami-software/umami.git
3sudo chown node:node -R /var/www/umami
4cd umami
5su node
6yarn install
Configure umami
Create an .env
file with the following
1DATABASE_URL=postgresql://umami:yourpassword@localhost:5432/umami
Build the application
1yarn build
The build step will also create tables in your database if you are installing for the first time. It will also create a login user with username admin and password umami.
Start the application with PM2
1pm2 start yarn --name umami -- start
2pm2 save
3pm2 startup
If port 3000, the default, is already in use (like with Gitea in my case for example), you can use the -p
flag like this pm2 start yarn --name umami -- start -p <port>
Reverse Proxy
You can access the application with the IP of wherever you’re hosting this web application and the port, in my case its 192.168.129.8:3001 because I’m behind NAT.
You will want to reverse proxy this web app with your favourite web server, in my case Caddy.
1umami.konakona.moe {
2 reverse_proxy localhost:3001
3 encode gzip
4}
That should be it, any questions, email me.
Created on: Saturday, 2 March 2024