How to Install Umami on Ubuntu 20.04
source link: https://www.vultr.com/docs/how-to-install-umami-on-ubuntu-20-04
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Introduction
Umami is a self-hosted web analytics alternative to Google Analytics that focuses on privacy. This guide explains how to install Umami on Ubuntu 20.04.
Requirements
- Deploy a fully updated Ubuntu 20.04 server with at least 2 GB of RAM.
- Create a fully qualified domain name for the server, such as umami.example.com.
- Install Node.JS and NVM.
- Install MySQL.
1. Create the Database
- SSH to your server as root.
Log in to MySQL as root.
# mysql -u root
Create a
umami
database and aumami_connect
user. Replace StrongPassword with a unique password.mysql> CREATE DATABASE umami; CREATE USER 'umami_connect'@'localhost' IDENTIFIED WITH mysql_native_password BY 'StrongPassword'; GRANT ALL PRIVILEGES ON umami.* TO 'umami_connect'@'localhost'; FLUSH PRIVILEGES;
Exit MySQL.
mysql> QUIT;
2. Install Umami
Clone the GitHub repository.
# git clone https://github.com/mikecao/umami.git
Change to the umami directory.
# cd umami
Install the necessary dependencies.
# npm install
Configure the database for Umami. When prompted, enter the password you chose for the umami_connect user.
# mysql -u umami_connect -p umami < sql/schema.mysql.sql
Create an environment file for Umami.
# nano .env
Paste the following to the file. Replace StrongPassword with the password you chose when you created the database. Replace the value of HASH_SALT with a unique value.
DATABASE_URL=mysql://umami_connect:StrongPassword@localhost:3306/umami HASH_SALT=Replace_This_With_A_Unique_Value HOSTNAME=127.0.0.1 PORT=3010
Save and exit the file.
Build Umami.
# npm run build
Install PM2 to automatically restart Umami in case of error or reboot.
# npm install pm2 -g
Launch Umami with pm2
# pm2 start npm --name "umami" -- run start-env
Generate a pm2 startup script and save the configuration.
# pm2 startup # pm2 save
3. Install Caddy as a Proxy Server
By default, Umami is only accessible from localhost. To expose Umami to the internet, use Caddy to proxy the connection and manage SSL certificates.
Install Caddy.
# apt install -y debian-keyring debian-archive-keyring apt-transport-https # curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc # curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list # apt update # apt install caddy
Edit the CaddyFile.
# nano /etc/caddy/Caddyfile
Replace the contents of Caddyfile with the following. Replace
umami.example.com
with your server's domain name.umami.example.com reverse_proxy 127.0.0.1:3010
Save and exit the file.
Start Caddy.
# caddy run
Verify Caddy is running and configured to restart after a reboot.
# systemctl status caddy
4. Test Umami
In your web browser, navigate to your server's domain name with HTTPS. For example:
https://umami.example.com
Log in as:
- Username: admin
- Password: umami
Next Steps
Please see the Umami documentation to learn how to use your new server.
Want to contribute?
You could earn up to $600 by adding new articles
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK