Introduction:

Umami, a simple, fast, and privacy-focused alternative to Google Analytics, helps webmasters in web traffic analysis for further optimization.

Deployment Method One: Installation Using Docker

Step One: Update the Source

apt update -y && apt upgrade -y        #Ubuntu/Debian
yum update -y && yum upgrade -y        #Centos

Step Two: Install Docker

curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh

Step Three: Create a Docker Volume for Storing Database Data

docker volume create umami-db-data

Step Four: Install and Start the PostgreSQL Container

docker run -d \
  --name umami-db \
  -e POSTGRES_DB=umami \
  -e POSTGRES_USER=umami \
  -e POSTGRES_PASSWORD=umami \
  -v ./sql/schema.postgresql.sql:/docker-entrypoint-initdb.d/schema.postgresql.sql:ro \
  -v umami-db-data:/var/lib/postgresql/data \
  --restart always \
  postgres:12-alpine

Step Five: Install and Start the umami Container

docker run -d \
  --name umami \
  --link umami-db:db \
  -p 3000:3000 \
  -e DATABASE_URL=postgresql://umami:umami@db:5432/umami \
  -e DATABASE_TYPE=postgresql \
  -e HASH_SALT="replace-me-with-a-random-string" \
  --restart always \
  ghcr.io/umami-software/umami:postgresql-latest

Note: The value of HASH_SALT should be replaced with a random string, which can be generated using the command openssl rand -hex 32.

Deployment Method Two: Installation from Source Code

Step One: Install Node.js and npm

Although the official documentation states that Node.js 12 or higher is sufficient, during actual use, the environment prompts you to install Node.js 16.13 or higher.

Run the following command to install:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

Verify if Node.js and npm are installed successfully:

node -v
npm -v

Step Two: Obtain the umami Source Code and Install Dependencies

git clone https://github.com/umami-software/umami.git
cd umami
npm install -g yarn

Step Three: Set up MySQL Database and Configure the Database for umami

Install MySQL server:

sudo apt-get update
sudo apt-get install mysql-server
sudo mysql_secure_installation

Log in to MySQL to create user and database:

sudo mysql -u root -p
CREATE USER 'umami'@'localhost' IDENTIFIED BY 'mypassword';
CREATE DATABASE mydb;
GRANT ALL PRIVILEGES ON mydb.* TO 'umami'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Create a .env file in the umami project directory with the following content:

DATABASE_URL=mysql://umami:mypassword@localhost:3306/mydb

Step Four: Build and Start umami

Return to the umami directory and run the following commands to build and start the application:

yarn install
yarn build
yarn start

Use a browser to log in to ip:3000 to check if the installation was successful. Initial username: admin, password: umami.

Step Five: Configure umami to Run in the Background and Autostart

Install PM2 and use PM2 to start umami

npm install -g pm2
pm2 start yarn --name "umami" -- start

Set up PM2 autostart hooks and save the current PM2 process list and state:

pm2 startup
pm2 save

Configure Web Traffic Analytics Code

  1. Add your website in Settings → Website → Add Website.
  2. Save, then click edit to view the tracking code.

  3. Add the tracking code to your website's code.
    Example: Typecho can be directly embedded in the header.php file.

Results Display:


Drawbacks:

This panel is suitable for personal use. Unregistered users cannot directly register and need the administrator to create an account.

Tag:Configure, umami, Web Traffic Analytics Tool, privacy-focused

Original link:https://enblog.fuyiran.link/Technology/12.html

Copyright: All posts on this blog, unless otherwise stated, are published using theCC BY-NC-SA 4.0 license agreement. Please indicate the source for reprinting Fu Speaking (enblog.fuyiran.link)

Add a new comment.