|:.:.:.:.:.:.:.:.:/.:.:.:.:.:./.:.:.:.:.:.:.:.:.:.:.:.:.:./|   '. :.:.:.:.:.:.:.:.:.:.l.ヽ:.:.:.:.l:.:.:.:.:.:.:.:.:.:∧\:.:.:.',
          |:.:.:.:.:.:.:./.:.:.:.:.:./.:.:.:.:.:.:.:.:.:.:.:.: , ′   l :.:.:.:.:.:.:.:.:.:| ∨.:.:.l:.:.:.:.:.:.:.:.:.:.∧ \:.'.
          |:.:.:.:.:.:/.:.:.:.:.: /.:.:.:.:.:.:.:.:. ヽ/ /    |:.:.:.:.:.:.:./:.:.|   y'.:.:|:.:.:.:.|:.:.:.:.:.:.∧   ヘ.
          |:.:.:.:./.:.:.:.//.:.:.:.:.:.:.:.:.:.:/ \,′   !:.:.:.:.:.:/|:.:./,/ '.:.:| :.:.:.|:.:.:.:.:.:.:.:.|
          |:.:.:/.:.:./.:./.:.:.:.:.:.:.:.:./   /` ‐-‐'|:.:.:./ |ァ'´    |:.:| :.:.:.|:.:.:.:.:.:.:.:.|
          |:.:.i.:.:./.:.:.: '.:.:.:.:.:.:.:/   ,/       |:.:.:/   ′    }.:.| :.:.:.|:.:.:.| :.:.:.:|
          |:.:.|:./.: rヘ|:.:.:.:.:.:/:.| 三三三三三  |:./   三三三 ハ|:.:.:.:.|:.:.:.| :.:.:.:|
          |:.:.l〃.:{  |:.:.:.:./.:.:.|             l.'         .i.:.:.i.:.:.:∧ :.:|ヽ :.:|
          |:.:./.:.:.:.\|:.:.:/.:.:.:.:|                '       |:.:.||:.:/  :.:.| '.:.:l
          |:./.:.:.:.:.:.:. !:./.:.:.:.:.:.'、            ,.ー--、    }.:.:|レ′ ∨  V
          |/.:.:.:.:.:.:.:.:V '´  ̄`ヽ.、            ´`¨¨{. |_.  '.:.:.:.|
         /.:.:.:.:.:.:.:./         ヘ `    . __. -r1 |:.:.:.:.:.:.:.:.|
         :.:.:.:.:.:.:, '         '. \    | _.   -┴ー──┴┐
         :.:.:.:.:./           |  \  r' |   -──────i'
    

< KONAKONA.MOE >

How to install Umami (Google Analytics Alternative)

Last Mod.: 2024-06-05 | Created On: 2024-03-02


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.


Prev:
How to Host a 4get Instance
Next:
How to install Zipline (ShareX/File Upload Server)