Use Tencent Cloud lightweight application server Lighthouse instance and Matomoo application image to build a website traffic statistics system

888u

Last update at :2024-02-14,Edit by888u

[Fun with Lighthouse in 5 Minutes] series of articles share tutorials on how to use lightweight application servers and provide rich practical guides to help everyone get started quickly and get the best product experience. This issue mainly introduces how to quickly build a website traffic statistics system by leveraging Tencent Cloud lightweight application server Lighthouse instance and Matomo application image.

Background overview

I recently tried to build a blog. After some research, I found that UP master Xiwaiwai_BILI's instructional video "How to Build the First Blog Site" can quickly implement a WordPress blog site with a lightweight application server. The construction process is clear and simple, saving time and effort. But after setting up a blog, it becomes a problem to collect statistics and observe site visit data. There are many related software on the market, but either the function support is not good, the security is not good, or there is a charge. Recently, the lightweight application server has launched the Matomo image, which can directly support the site statistics function through simple initialization settings, and it is very smooth to use.

What is Matomo?

Matomo is an open source website data statistics software that can be used to track and analyze the traffic of your website while fully ensuring data security and privacy. Its interface functions are friendly and easy to understand, with low barriers to use, a strong open source community, and strong version iterations (5 versions updated between March 2022 and May 2022).

You don’t have to worry about tedious package dependency installation and configuration, and you don’t have to worry about compatibility and version adaptation between PHP, Nginx, MariaDB and Matomo. Next, we can easily start the Matomo mirror experience journey through Tencent Cloud lighthouse.

Create a Matomo lightweight application server

Open the lightweight application server and enter the console. You can see the Matomo image for the newly purchased instance.

Choose the Matomo image to create a lightweight application server. After creation, open the "Application Management" tab under the console instance. You can see that the Matomo image version of the current image is 4.9.1, and Nginx 1.20.2, PHP 7.4.29 and MariaDB 10.5.15 are preset in the image. Relevant version dependencies.

In addition, there are access addresses for Matomo initialization, how to obtain the initial password for MariaDB, and installation addresses for each software.

Matomo initialization settings

After creating a Matomo instance and having a certain understanding of its functions. Let's start the initial setup and use of Matomo.

Continue to stay on the "Application Management" tab under the above console instance, click the "Access Address" browser to open Matomo's service page, and you can see the Welcome page.

Click Next, the Matomo environment check interface appears.

Scroll down and continue to click Next (you can ignore the SSL option prompt here first, and you can configure it if necessary for security reasons later. Ignore the recommended items of fpm-fcgi and nginx/1.20.2. If there are other check items that have not passed, you need to do it yourself. troubleshooting). The database initialization settings page appears.

Enter according to the prompt information in the figure. The method of obtaining the MariaDB user name and password has been introduced when creating the Matomo instance. Continue to click Next and see that the database and table have been created successfully.

Continue to click Next to see the super username and password settings,

After filling in the information in the picture, click Next to see the website information setting interface you want to track (the picture is filled in as an example)

Click Next to see that the tracking code used for site statistics has been generated.

Continue to click Next. When you see the Congratulations page, continue to click Next. The login page pops up.

Matomo performs site statistics

Enter your login username and password as prompted and click SIGN IN to log in. After logging in, you can see the eye-catching tracking code under the system label and Dashboard.

Copy all the code in the red box to the relevant section of your blog.

If we take Lighthouse's WordPress mirroring service as an example, just open the management system, enter the "Theme Editor" under "Appearance", select header.php, and copy the tracking code copied in the red box to the front of Location, click "Update File" in the lower left corner to take effect.

(Note: Sometimes clicking on the update file may not take effect due to version issues. In this case, it is recommended to find the relevant header.php under the blog service/usr/local/lighthouse/softwares/wordpress/wp-content/themes/ and modify it directly. )

Click to visit your blog website, Matomo can count the visit information.

As shown in the figure, Matomo access client access time, location, access page records, terminal operating system and browser information can be statistically recorded.

If you want to add a new website, click All Websites

Then click the red box "Add a new website". Add site.

Click on the Dashboard tab, select the newly added blog site in the upper left corner, and copy the tracking code to the relevant section of the corresponding site as described above.

Finally, both sites can successfully implement access statistics.

Matomo’s domain name settings

If you want the matomo service to be bound to a domain name, bind the domain name to the Matomo server IP in advance.

On the service side, you need to add the domain name to /usr/local/lighthouse/softwares/matomo/config/config.ini.php.

Add domain name and access

Matomo’s https settings

For transmission security reasons, it is often necessary to configure https for the Matomo service. You can apply for a certificate through the Tencent Cloud SSL certificate. Refer to the official Nginx https configuration to configure matomo.conf under /usr/local/lighthouse/softwares/nginx/conf/include. In addition, you can optionally configure config.ini.php under /usr/local/lighthouse/softwares/matomo/config and add force_ssl = 1 under [General]. Then restart the nginx service and successfully access the Matomo service through https.

Tencent Cloud 618 event is currently in progress. Tencent Cloud 618 purchasing season: 2C4G6M lightweight server starts at 128 yuan/year, and 2C2G4M starts at 18 yuan for three months.

Recommended site searches: Beijing host rental, German server, Japanese server rental Japanese server, domain name, host space, ip query Chinese domain name registration, high-defense server, domain name resolution server, personal domain name registration,

Use Tencent Cloud lightweight application server Lighthouse instance and Matomoo application image to build a website traffic statistics system

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码