当前位置:网站首页>Deploy website traffic statistics background based on Tencent cloud lightweight application server and umami
Deploy website traffic statistics background based on Tencent cloud lightweight application server and umami
2022-06-11 20:32:00 【Mintimate】
Website traffic statistics
Want to know your website , How many people browse every day ? Or you want to view the visitor statistics of your website more intuitively ? A lot of people use Google Analytics And other tools . General statistical data :
- Number of website visitors per day
- Average page length of visitors
- Source of visit ( Jump from what website to your own website )
- ……
however , Some third-party tools , Access is complex , And the data is not in your own hands , Worry about personal data being optimized by third-party platforms 、 User modeling, etc .
Come and try Umami, One is based on Nodejs Development of the website browsing statistics system , Build your own website statistics background , Even a complete victory .
Umami
Umami be based on Node.js Development , All data is stored in their own Mysql( Of course , Support MariaDB) or Postgresql Inside . Don't worry about your data being “ Whoring for nothing ” Or abuse .
Very curious , use separately MySQL database ,Umami How to solve the problem of high concurrency ,“ Fantasy reading ” perhaps “ Dirty reading ” The problem of ? Have the opportunity to study the source code ~~
Umami Open source address :https://github.com/mikecao/umami
Umami Official document address :https://umami.is/docs/about
Lightweight application servers
Unami You need your own server , Tencent cloud lightweight application server is recommended here , At the same time, if you haven't filed your domain name , Hong Kong, which can use Tencent cloud lightweight application server first 、 Singapore server , At a very low price , Fast build .
Compared with traditional CVM, Faster deployment , More wallet friendly , and Use lightweight application servers , Deploy an application , perfect , I bought a lot of servers myself , Deploy multiple applications :
preparation
In terms of core hardware , Only one server is needed . But if you want to improve the experience , It is recommended that :
- domain name : Easy to use domain name and HTTPS Visit the Umami backstage , Safer and more convenient .
- CDN: Use CDN( Like Tencent cloud CDN) Domain name access , Speed up website access , At the same time, the server is protected to a certain extent IP.
The second is software , need :
- MySQL/MariaDB:Umami Data storage .
- Nginx: Use Nginx, Yes umami Default 3000 Port for reverse proxy .
- Nodejs: If you have not installed Nodejs, You can read this article =>https://www.mintimate.cn/2021/07/26/nvmNode/
This tutorial , To take care of Xiaobai ; Demonstrate both conventional and pagoda methods ; If you haven't used any servers before , You can use the pagoda method to build .
Server purchase
The first is to purchase Tencent cloud lightweight application server , I suggest you buy a pagoda image version , Or pure Debian edition :
A little friend who uses pagoda image , You can initialize the server , Visit the pagoda panel , install :
install umami
after , We need to SSH Remote connection to our Linux The server ;
If this is your first time using Linux The server , I don't know how to connect to the server , Can view tutorials :
clone umami Warehouse
After connecting to our server remotely , We need to clone umami The warehouse of :https://github.com/mikecao/umami
We just use git Just clone :
git clone https://github.com/mikecao/umami
If your server cannot connect GitHub, have access to Github Speed up
Installation dependency
Installation dependency , need Nodejs Support for , If you do not install Nodejs, You can view articles :
after Enter the newly cloned warehouse Inside , We can then install the dependencies :
# Enter the newly cloned warehouse cd umami # Use NPM Do dependency installation npm install
Here we are , Dependent installation ends , We need to initialize the database .
Initialize database
Initialize database , Here are two ways to show you :
- Conventional methods : Configure and install by yourself MySQL Database situation .
- Pagoda method : Using pagoda to install database .
If you don't want to use pagoda panels , But I don't know how to configure it manually MySQL/MariaDB, Reference article :
- An article , Four ways to teach you in Linux Installation on MariaDB
- An article 、 There are three ways Debian Easy to install on Nginx
Conventional methods ( Non Xiaobai is recommended )
Conventional methods , Make sure you have installed MySQL perhaps MariaDB, I am out of personal habit , Installation is MariaDB:
It's simple , I initialize the database : Log in to the database - Create a new database - Create a new user - Bind database - use umami Self contained SQL initialization .
If you have any other needs , You can change ( such as : If safety is not required , It can be used directly root User initiated database ).
Logging into the database is too easy , I set the database to log in locally without a password , therefore :
# Log in to the database mariadb
Database and users
I believe that the little friend who looks at the conventional method , It must be true SQL I know something about it , Let me just say something roughly :
# Create a user , And allow the local machine to access CREATE USER 'umami'@'localhost' IDENTIFIED BY 'E51H1c1c'; # Create a database CREATE DATABASE umami;
among :
E51H1c1c: The database password I set .- Database and user? I name them both umami, Easy to classify .
- I only allow local login , Convenient for safety management .
User rights are granted to
after , We put the newly created database , Leave it to the new user to manage :
GRANT ALL ON umami.* TO 'umami'@'localhost';
Then quit MariaDB Interaction :
SQL initialization
umami Bring their own SQL file , Let's initialize the database :
therefore , We can extract and run :
mariadb -u umami -p umami < sql/schema.mysql.sql
among :
-u umami: Use umami Account ;-p umami: Theoretically-pRepresents the use of a password , But this represents using a password to access ,umami Represents the database accessed .
Here we are ,SQL The initialization of is completed , You can log in. MariaDB Look at the :
Pagoda method ( Recommend Xiaobai )
The pagoda method is very simple , In the pagoda , Create a new database :
after , go back to Terminal Inside , Using umami Self contained SQL File for database initialization :
mysql -u umami -p umami < sql/schema.mysql.sql
among , The password will be hidden automatically , Directly copy the pagoda in the background , Paste here .
Here we are ,SQL The initialization of is completed .
Configuration environment
umami We need to configure a .env The environment of umami root directory , after umami Meeting Read this file to connect to the database “Hash Add salt ”.
vim .env
We just use vim Create , And write :
DATABASE_URL=mysql://umami:[email protected]:3306/umami HASH_SALT=Mintimate
among :
- first
umamiUsername E51H1c1cFor the user password- the second
umamiFor the database HASH_SALTby Hash Salt character , Any string can .
Once configured , Save and push . If you don't know vim The operation of , The operation panel can be used , Or check out the article :
Or directly use the pagoda panel to operate :
Because I bought two lightweight application servers for demonstration at the same time ( A pagoda mirror , a Debian), therefore Umami The installation address of is sometimes different ; Everyone should remember their own Umami Installation address .
structure umami
Last , We can have our own configuration ( database ), Conduct umami The construction of , It's simple , Use command :
npm run build
Be careful , Here you need to download the dependency package , There are no nodes in Chinese Mainland depending on the package download address ; therefore , Continental servers may be slow to build , Even build failure .( Tencent cloud lightweight application server in Hong Kong 、 Singapore will be faster )
Build failed , Just run it again
npm run build
function umami
after , We can use :
npm run start
start-up umami:
This is the time , You can access it with a browser . But in order to be more convenient , We use Nginx Reverse proxy .
Background operation
in addition , It is recommended to run in the background umami, have access to screen:https://cloud.tencent.com/developer/article/1844735
Of course , You can also register as systemctl service , Registration content reference :
[Unit] Description=NodeServer [Service] ExecStart=/……/npm start Restart=always Environment=PATH=/usr/bin:/usr/local/bin:/……node/bin Environment=NODE_ENV=production WorkingDirectory=/YourWorkPath/umami/ [Install] WantedBy=multi-user.target
The final result :
This …… Have the opportunity to video this article , Let me show you ; Or another article Systemctl The tutorial is for you .
Nginx Reverse proxy
In order to be able to use Https visit , Or use 443、80 Port access , Not strange IP+3000 port , This strange way to access umami. We use Nginx Reverse proxy :
Normal operation
Normal operation , We compile and install it ourselves Nginx, We compile Nginx To configure , Add reverse proxy configuration :
location /{
proxy_pass http://127.0.0.1:3000/;
}Pagoda operation
Of course , You can also use the pagoda to operate :
First, add the domain name to the pagoda :
Then reverse proxy :
If you don't know the domain name resolution , You can refer to Tencent cloud's DNS file :https://cloud.tencent.com/document/product/302/2589
How to use
First , Let's go backstage , Create a website :
after , We copy the trace code , To your own website <head> Just paste it inside :
I am a Vue project , Put it in the root directory index.html that will do ; Redeployment :
You can track website data :
Final effect
Of course , You can also look at the source of users :
It is convenient for us to..., according to user preferences , Write something users like , Or adjust the development direction of your website 、SEO Optimization, etc. . Like in the picture , Most users are bing From the search engine , Why doesn't Baidu search engine ? May be SEO optimization problem , Or Baidu article content , Baidu crawler doesn't like it... Etc .
The only deficiency is ,IP The library is not complete ( Capable little friends , You can change it (*≧ω≦)):
END
Here we are ,Umami Just install and deploy the website . Do you have any friends who want to know how to OTA Upgrade ?
In fact, the government also provides methods , Only need Umami Without operation , again pull And install and build dependencies that will do :
# here Umami Is not running ,Terminal be in Umami inside address git pull # Dependent on reinstallation npm install # Rebuild project npm run build # Restart project ( If you have configuration Systemctl, have access to ) npm run start
边栏推荐
- 10 R vector operation construction
- 2022-2028 current situation and future development trend of fuel cell market for cogeneration application in the world and China
- Log in with password and exit with error for three times.
- ICML 2022 𞓜 rethinking anomaly detection based on structured data: what kind of graph neural network do we need
- [advanced MySQL] differences among 10 data types and how to optimize the table structure (3)
- Object storage of CEPH distributed storage
- 8 r subset
- AHB2APB_ Bridge design
- Current situation and future development trend of global and Chinese cogeneration system market from 2022 to 2028
- Calculation of Zeno paradox
猜你喜欢

29. location對象

Chinese text classification based on CNN

The tutor transferred me 800 yuan and asked me to simulate a circuit (power supply design)

这些考研专业容易混淆,搞错就白考啦!

Explanation of LNMP architecture source code compilation and installation with pictures and texts (with forum experiment)

Database introduction

Implementation of SQL online editor based on Vue + codemirror

In 2021, the global ceramic substrate revenue will be about US $409.7 million, and it is expected to reach US $657.3 million in 2028

Leetcode 1992. 找到所有的农场组(可以,一次过)

Object storage of CEPH distributed storage
随机推荐
导师转我800块,让我仿真一个电路(电源设计)
moderlarts第一次培训
The first bullet of comparative learning
Log in with password and exit with error for three times.
Leetcode 1992. Find all farm groups (yes, once)
输入值“18-20000hz”错误,设置信息不完整,请选择单位
Final examination of Dialectics of nature 1
Windows icon display exception resolution. The desktop icon is abnormal, the start menu icon is abnormal, and the taskbar icon is abnormal. Icon cache location.
Installation and performance test of Apache APIs IX on Amazon graviton3
STC hardware only automatic download circuit V2
Unity截屏
7905 和TL431 负电压稳压电路 - 相对于电源正极的稳压和浮地电路
Oracle case: ora-00600: internal error code, arguments: [4187]
What is the essence and process of SCM development? Chengdu Automation Development Undertaking
UDP、TCP
A mechanics informed artistic neural network approach in data driven constructive modeling
接口隔离原则
Apache APISIX 在Amazon Graviton3 上的安装和性能测试
29. Objet de localisation
RTL arbiter design