Independent testing Updated April 2026 387 self-hosting guides 5 VPS providers tested

guide

How to Self-Host Matomo on a VPS (Complete Guide)

Learn how to self-host Matomo on a VPS with a step-by-step guide covering installation, configuration, and securing Matomo for reliable daily use.

How to Self-Host Matomo on a VPS (Complete Guide)

Matomo is an open-source web analytics platform that gives you complete control over your data. Self-hosting Matomo on a Virtual Private Server (VPS) provides flexibility, performance, and privacy compared to third-party analytics solutions. This guide will walk you through the steps to self-host Matomo on a VPS, with an emphasis on installation methods and configuration.

Why Choose a VPS for Matomo?

Self-hosting Matomo on a VPS allows developers to customize their environment and ensures compliance with data privacy regulations. A VPS offers several benefits:

Hereโ€™s a quick comparison of some top VPS providers, reflecting on cost and features:

ProviderStarting PriceFeatures
Contabo VPS5.99 EUR/moHigh storage, good support
Hetzner Cloud4.15 EUR/moFlexible pricing, good performance
DigitalOcean6 USD/moEasy setup, developer-friendly tools
Vultr6 USD/moGlobal data centers, simple billing
Linode5 USD/moConsistent performance, robust API

You can check out the full VPS comparison for more details.

Prerequisites

Before you start, ensure you have the following:

Providers like Contabo, Hetzner, and DigitalOcean are excellent choices.

Step 1: Setting Up the Environment

Log into your VPS using SSH:

ssh root@your_vps_ip

Update the package list and install necessary dependencies:

sudo apt update && sudo apt upgrade -y
sudo apt install apache2 mysql-server php php-mysql php-cli php-curl php-gd php-xml php-mbstring unzip -y

Step 2: Configuring the Database

Log into MySQL to create a new database and user:

sudo mysql -u root -p

Execute the following commands:

CREATE DATABASE matomo_db;
CREATE USER 'matomo_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON matomo_db.* TO 'matomo_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

This sets up a database for Matomo, ensuring that you have a dedicated user.

Step 3: Downloading and Configuring Matomo

Now, download Matomo from the official site:

cd /var/www/html
wget https://builds.matomo.org/matomo-latest.zip
unzip matomo-latest.zip
rm matomo-latest.zip

Adjust permissions for the Matomo directory:

sudo chown -R www-data:www-data matomo
sudo chmod -R 755 matomo

Step 4: Setting Up Apache

Create a new Apache configuration file:

sudo nano /etc/apache2/sites-available/matomo.conf

Add the following configuration:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/matomo
    ServerName yourdomain.com

    <Directory /var/www/html/matomo>
        Options FollowSymLinks
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/matomo_error.log
    CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined
</VirtualHost>

Enable the new configuration and the rewrite module:

sudo a2ensite matomo.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 5: Completing Installation via Web Interface

Open your web browser and navigate to http://yourdomain.com. Follow the on-screen instructions to complete the installation. Youโ€™ll need to provide the database information created earlier:

After successful setup, you can log in to your Matomo dashboard.

Optional: Installing Matomo with Docker

If you prefer to use Docker for installation, hereโ€™s a quick guide:

  1. Install Docker on your VPS:
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
  1. Pull the official Matomo Docker image:
docker pull matomo
  1. Run the Matomo container:
docker run -d --name matomo -e MATOMO_DB_HOST=db -e MATOMO_DB_USER=matomo_user -e MATOMO_DB_PASS=your_password -e MATOMO_DB_NAME=matomo_db -p 80:80 matomo

This will set up Matomo using Docker with minimal configuration.

FAQs

How much does it cost to self-host Matomo on a VPS?

The cost of self-hosting Matomo depends on the VPS provider you choose. Providers like Hetzner Cloud offer plans starting at 4.15 EUR/month, while others like Contabo start at 5.99 EUR/month. DigitalOcean and Vultr also provide competitive pricing at around 6 USD/month. Ensure that your plan has enough resources to handle your analytics needs.

What technical skills are required to install Matomo on a VPS?

To install Matomo, youโ€™ll need a basic understanding of Linux, familiarity with SSH, and knowledge of web server configurations. Understanding MySQL database management is also beneficial since youโ€™ll need to create a database for Matomo. For those unfamiliar with these concepts, numerous online resources, including r/selfhosted, can provide guidance.

Can I migrate from an external Matomo instance to my self-hosted version?

Yes, you can migrate your data from an external Matomo instance to your self-hosted version. Export your data from the existing Matomo instance and import it into your new setup. Refer to Matomoโ€™s official documentation for detailed steps on backup and migration to ensure a smooth transition.

By following this guide, you can successfully self-host Matomo on a VPS and gain control over your web analytics.