How to Deploy umami - A Simple but Useful Web Traffic Analytics Tool
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 #CentosStep Two: Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.shStep Three: Create a Docker Volume for Storing Database Data
docker volume create umami-db-dataStep 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-alpineStep 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-latestNote: 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 nodejsVerify if Node.js and npm are installed successfully:
node -v
npm -vStep Two: Obtain the umami Source Code and Install Dependencies
git clone https://github.com/umami-software/umami.git
cd umami
npm install -g yarnStep 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_installationLog 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/mydbStep 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 startUse 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" -- startSet up PM2 autostart hooks and save the current PM2 process list and state:
pm2 startup
pm2 saveConfigure Web Traffic Analytics Code
- Add your website in Settings → Website → Add Website.

- Save, then click edit to view the tracking code.


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.
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)