How to Install Matomo on VPS Hosting Servers?

LightNode
By LightNode ·

Matomo, formerly known as Piwik, is an open-source web analytics platform. It provides detailed reports on a website's traffic, search engine referrals, marketing campaigns, and visitor behavior. Unlike Google Analytics, Matomo emphasizes privacy and data ownership, giving users full control over their data.

There are many ways to install Matomo, this article will teach you to install Matomo using one of the easiest methods, all you need to do is prepare a LightNode VPS server and install it successfully with a few lines of commands.

Processes

Buy a VPS

Buy a LightNode VPS with Docker image.

Docker Image

Buy Docker VPS

Connect to VPS

Use SSH tools to connect to VPS.

Install Matomo

  1. Pull the Matomo Docker Image
docker pull matomo
  1. Start the Database

Matomo requires a MySQL or MariaDB database. You can use Docker to start one:

docker run --name matomo-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=matomo -e MYSQL_USER=matomo -e MYSQL_PASSWORD=matomo-pass -d mysql:latest

In this command, we're using the mysql:latest image and setting up the database name, user, and password. Make sure to replace my-secret-pw and matomo-pass with your own secure passwords.

  1. Start the Matomo Container

Now, link the Matomo container to the MySQL container and start it:

docker run --name matomo --link matomo-mysql:mysql -p 8080:80 -d matomo

Here, we are using the --link option to link the Matomo container to the MySQL container. We are also mapping port 8080 to Matomo's default port 80.

  1. Access Matomo

You should now be able to access the Matomo installation wizard in your web browser at http://your_ip_address:8080. Follow the wizard to complete the installation.

  1. Configure the Database Connection

During the installation process, when prompted to set up the database connection, use the following settings:

  • Database Server: mysql
  • Login: matomo
  • Password: matomo-pass (or whatever password you set in step 3)
  • Database Name: matomo

This is a basic setup suitable for a quick start or development environment. For production environments, you might need to consider additional factors such as data persistence, security, performance optimization, etc.

FAQ

Q: Why do I need to start a MySQL container separately?

A: Matomo requires a database to store its data. By starting a MySQL container, you provide Matomo with the necessary database server. You can also use other database servers like MariaDB.

Q: Can I use an external database instead of running a MySQL container?

A: Yes, you can. If you have an existing MySQL or MariaDB database server, you can use it for Matomo. Just make sure to provide the correct database connection details during the Matomo setup.

Q: How do I ensure data persistence for my Docker containers?

A: To ensure data persistence, you should use Docker volumes to store the database data and Matomo configurations. Without volumes, the data will be lost when the container is removed.

Q: What are the default login credentials for Matomo?

A: During the installation process, you will be prompted to create an admin account for Matomo. The username and password for this account will be the credentials you use to log in.

Q: Can I customize the Matomo Docker container settings?

A: Yes, you can customize various settings such as port numbers, environment variables, and more by modifying the docker run command used to start the container.

Q: How do I update Matomo on Docker?

A: To update Matomo, you can pull the latest Docker image and recreate the container. Make sure to backup your data before updating.