Roll Your Own Google Analytics Alternative with Umami 🌱

What is Umami

Umami is a simple, fast, website analytics alternative to Google Analytics. -https://github.com/mikecao/umami

Installing NodeJS

  1. Log into the Linux device
  2. Run the following commands in a terminal window
    # download nodejs
    wget -O nodejs.tar.xz https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz
    # extract nodejs.tar.xz
    tar -xJf nodejs.tar.xz
    # change directory to extracted folder
    cd node-v14.17.0-linux-x64
    # copy node binaries to /usr/local
    sudo cp -R * /usr/local/
    # test node is working
    node -v
    # test npm is working
    npm -v

Running Umami

  1. Run the following commands in a terminal window
    # install MySQL
    sudo apt install mariadb-server -y
    # configure the MySQL database
    sudo su
    mysql_secure_installation
  2. Press Enter to login as root
  3. Type Y and press Enter to set a root password, type the password twice to confirm
  4. Type Y and press Enter to remove anonymous users
  5. Type Y and press Enter to disallow root login remotely
  6. Type Y and press Enter to remove the test database
  7. Type Y and press Enter to reload privilege tables
  8. Run the following command to login into MySQL:
    mysql -u root -p
  9. Authenticate with the root password set earlier
  10. Run the following commands to create the database and database user
    CREATE DATABASE umami DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    GRANT ALL ON umami.* TO 'umami_rw'@'localhost' IDENTIFIED BY 'um@m1!';
    FLUSH PRIVILEGES;
    EXIT;
    exit
  11. Continue with the following commands:
    # install git
    sudo apt install git -y
    # cd back to home
    cd ~
    # clone umami github repo
    git clone https://github.com/mikecao/umami.git
    # cd into git clone
    cd umami
    # import database structure
    mysql -u umami_rw -p umami < sql/schema.mysql.sql
    # install dependencies
    npm install
    # create and edit .env
    nano ./.env
  12. Paste the following into .env

    DATABASE_URL=mysql://umami_rw:um@m1!@localhost:3306/umami
    HASH_SALT=SomethingSecure

  13. Press CTRL+O, Enter, CTRL+X to write the changes to .env
  14. Continue with the following commands:
    # build umami
    npm run build
    # run umami
    npm start
  15. Open a web browser and navigate to http://DNSorIP:3000
  16. Login with the username admin and password umami
  17. Navigate to Settings > Profile and click the Change Password button
  18. Enter the current password (umami) and enter and confirm the new password > Click save