
Matomo is an open-source web analytics solution designed to preserve your site visitors' privacy. Unlike Google, you have full ownership of your data and control over where it is stored.
This article covers installing Matomo using its latest release file and Docker. Follow the installation method that best fits your setup.
Before you begin, you need to:
matomo.example.com for demonstration. Replace all occurrences with your domain name.The Matomo release file is a ZIP archive that contains the web application code needed to deploy Matomo analytics. Follow the steps below on your Ubuntu server.
Update the apt package index.
Download the release file using wget.
The release file is downloaded and saved as matomo.zip.
Extract the compressed file.
This command extracts the files to /var/www/ and creates a directory matomo containing the web application files. The extracted files are owned by the user root and group root.
Set the file ownership for Matomo to the www-data user and group.
Set the permissions to allow read, write, and execute for the user, read and execute for the group, and no permissions for others.
The web server can now read, write, and execute all files in the Matomo directory.
LEMP is a stack of Linux, Nginx web server, MySQL database, and PHP. Follow the steps below to set up the LEMP stack on your server.
Install Nginx.
Allow Nginx on the UFW firewall.
Enable and start Nginx.
Verify Nginx is running by sending a request with curl.
Output:
Nginx is installed and running on port 80 (HTTP). To confirm, visit http://SERVER_IP in the browser. Substitute SERVER_IP with your server's public IP.
MariaDB is an open source database management system that is a drop-in replacement for MySQL. Install MariaDB.
Secure MariaDB by running the mysql_secure_installation utility.
ENTER key since there is no password set.Switch to unix_socket authentication [Y/n] - Enter Y to accept the change.Change the root password? [Y/n] - Enter Y to change the root account password.Remove anonymous users? [Y/n] - Enter Y to remove anonymous users.Disallow root login remotely? [Y/n] - Enter Y to disable remote login for your database.Remove test database and access to it? [Y/n] - Enter Y to remove test database.Reload privilege tables now? [Y/n] - Enter Y to reload the privileges to apply the changes.Enable the database service.
Verify that MariaDB is running and ready to accept connections.
Sample output:
MariaDB is running and ready to handle connections.
Install PHP-FPM and required extensions.
This installs the PHP FastCGI Process Manager and the required extensions. PHP-FPM is necessary because Nginx cannot process PHP source files directly.
Enable the PHP-FPM service to start automatically at boot.
Download the FastCGI configuration file to the Nginx configuration directory.
The file is downloaded to the location /etc/nginx/conf.d/.
Download the Matomo configuration file for Nginx from GitHub:
Edit the Matomo configuration file.
Edit and modify it to match the following example. Replace the matomo.example.com value in the server_name directive with your actual domain name.
Test the configuration.
If the configuration file has no issues, you'll get the output below.
Reload Nginx.
Nginx is ready to handle incoming requests. However, you must install and configure the database server to store all the analytics data.
Before configuring Nginx to serve Matomo, you must create a database to store the data collected.
Connect to MySQL to start creating the database and user:
Enter the password you set as the MySQL root password earlier.
Create a database to store analytics data:
Create a dedicated user for Matomo:
Grant the user the required database permissions to manage analytics data.
Grant the FILE privilege for faster report archival:
Exit MariaDB.
To secure the Matomo analytics web interface, use certbot to deploy TLS certificates from Let's Encrypt.
Install the certbot utility and Nginx plugin.
Deploy a certificate for your Matomo subdomain.
Visit the https://matomo.example.com webpage in a web browser.
After installing Matomo directly on the operating system or in Docker, visit https://matomo.example.com to start configuring your installation. The default page lists the steps you need to perform before you can use Matomo with a progress bar on the top right corner.
Click Next on the welcome page.
Matomo checks the system configuration to verify that it meets the installation prerequisites. This includes properties such as the Matomo version, PHP version, memory limit, and required extensions.
Scroll down and click Next.
On the third step, configure the database parameters. Enter the details you provided during the Matomo installation. Enter the database server as db for Docker installation and provide your defined password.
Matomo creates the necessary tables. Click Next to proceed to set a Superuser account.
Set up the Superuser, an administrative account with unrestricted access. Choose a username, a secure password, and enter your email address. You may opt into emails by checking the confirmation boxes.
Enter the details of the first website, including a name, URL, and timezone. Specify whether it is an e-commerce site as well.
Copy the generated tracking code and paste it just before the closing </head> tag on your website pages.
You have set up tracking for your first website.
Continue to the final page, which summarizes the setup. You can then proceed to the sign-in page. Enter the superuser credentials created earlier.
Upon successful login, the Matomo dashboard loads, where you can explore additional ways to add tracking to your websites.
In this article, you have learned how to install Matomo analytics on an Ubuntu server using its latest release file and Docker. You have also learned to perform the initial setup to create a superuser account. The superuser can create more accounts on the system and grant limited access to specific domains for every user.
The Matomo website has additional resources to help you learn more and increase your proficiency. Visit the Matomo help page to explore documents and video materials to kickstart your journey.
0 Comments
Be the first to comment and share your perspective with the community.