GuidesBusiness and monitoringMatomo web analytics

Run Matomo web analytics with rootless Docker

Matomo 5 on Debian 13, the open-source alternative to Google Analytics with goals, ecommerce, campaigns and email reports, in rootless Docker with MariaDB under a user of its own behind Caddy, set up for EU privacy and with outside connections off.

Tested on Docker steps follow the tested rootless Docker base guide on Debian 13 with Docker Engine 29.10.1, Compose 5.8.1 and rootlesskit 3.3.0; the app version and app-specific behaviour are from the tested Podman guide on a Melonslab server. Not re-tested end to end under Docker. Updated November 28, 2026

Recommended server for this guide

SSD RAID 1 · ECC DDR4 · 10 Gbit

VC-P Alloy · 2 vCPU · 8 GB Memory · 60 GB Storage

Month to month, no lock-in 7-day money-back guarantee

€8.99/mo

Deploy now

Quick install on a fresh VM

This command sets up a rootless container engine and a directory for this service. Podman is the default; add --engine docker to the command to use Docker instead.

curl -fsSL https://www.melonslab.com/install/rootless.sh | bash -s -- --app matomo-docker --manifest matomo --sha256 99eb26306df26fa4ca819cf292871810bc0d0ab6ce4e548883e1807eb8a5f034
View the script

SHA-256: 97785be3e3e91393181a4a7caeab5f4b52803bf52e960dd488945cb38c6473a2

Run this guide on Melonslab

We ran every step below on our own server. For this workload we recommend VC-P Alloy at €8.99/mo. Order it, pick Debian 13, and follow the guide.

  1. 1. Order the server. Use the button below to order the recommended plan. Choose Debian 13 when the installer asks for an operating system.
  2. 2. Add IPv4 if needed. Add it on the order form when the guide publishes a service on the internet. It is a paid add-on, not included in the plan.
  3. 3. Connect over SSH. Log in as root with the address and credentials from your order, then run the commands below.
  4. 4. Follow the verified steps. Every command in this guide was run on a Melonslab server before it was published.
Deploy now
On this page

What you will set up

Matomo is the most complete open-source alternative to Google Analytics. Besides visits, pages, sources and locations, it tracks goals, ecommerce orders and revenue, campaigns, site search and events, keeps a log of each visit, sends reports by email, and lets you give colleagues view-only access. All visitor data stays in a database on your own server.

Matomo started in 2007 as Piwik, created by Matthieu Aubry. It is developed by InnoCraft Limited, a company registered in New Zealand that was started by Matomo's creators and also sells Matomo Cloud and paid plugins. Matomo is open source under the GNU General Public License version 3 or later, which we checked in its source code on 14 October 2026.

Here Matomo runs as a Compose project under a user of its own called matomo, with MariaDB for its data, behind Caddy from the Docker guide. The image is the official matomo image on Docker Hub, maintained by the Matomo community. It comes in two kinds: apache, with Apache and PHP in one container, and fpm, with PHP only, which needs a web server that can read Matomo's files. This guide uses apache: Caddy runs under its own user and cannot read the files of the matomo user, so fpm would need a second web server in the pod. With apache, Caddy only passes requests on, as for every other app.

The app-specific results below come from the tested Podman guide on a Melonslab server with Debian 13:

  • Matomo 5.14.0 started with MariaDB 12.3.3, and the installer and the super user account were done over an SSH tunnel before Caddy made Matomo public.
  • A small test website with Matomo's tracking code was visited in a browser. The visit showed the visitor's real address, shortened to its first two parts, and the right city, over IPv4 and IPv6. A forged X-Forwarded-For header was ignored.
  • 1,200 simulated visits were sent through Matomo's Tracking HTTP API over a week, with real browser user agents, addresses from six countries, referrers, two UTM campaigns, two goals, 34 ecommerce orders, site searches and video events. They are not real people. The hourly timer built the reports, and the numbers matched what was sent, with each goal counted once per visit.
  • With Force tracking without cookies on, the browser got no cookies. With Do Not Track support on, a visit that sent DNT: 1 was not recorded. The opt-out on a privacy page stopped all tracking for that browser.
  • A view-only user accepted an invitation and could see the reports but not the settings. A weekly report arrived by email, in a mail catcher on the server.
  • The interface was shown in by choice and for a browser set to Swedish. The free Google Analytics importer was installed, but not used, since that needs a Google account.
  • A capture of the server's traffic listed every outside service Matomo contacted, and none after step 15.
  • Matomo was updated from 5.13.0 to 5.14.0. It was restored from a backup for a newly created matomo user, with all visits, reports, goals and users, and everything came back by itself after a reboot.

In the Podman test, after a reboot, the pod used about 170 MB of memory: MariaDB 130 MB and Matomo 40 MB. With the dashboard in use, Matomo grew to about 150 MB, and while it built the reports for the test visits, the pod peaked at about 420 MB. The 1,200 visits, with about 3,500 pageviews and other actions, added about 1 MB of raw data and 2 MB of reports to the database, so plan for roughly 1 MB of raw data per 1,000 visits. The two images take 960 MB on disk. Steps 1 to 7 took us about 10 minutes.

Matomo, Plausible or Umami? All three keep the visitor data on your server. Matomo does the most: ecommerce revenue, goals with conversion rates, campaigns, a log of each visit, site search, segments, scheduled email reports, users with view-only access, a Google Analytics importer. It sets cookies until you switch them off, and its privacy settings are yours to choose, which takes the longest of the three. Plausible and Umami set no cookies from the start and show one simpler dashboard. Umami used about 210 MB of memory in our comparison, Plausible about 650 MB with ClickHouse, and Matomo about 170 MB here, more while it builds reports. If you need ecommerce, campaigns and email reports for a team, pick Matomo; if you want visits and sources with the least work, pick one of the other two.

The Docker version below follows the tested rootless Docker base guide. The app-specific results above come from the tested Podman guide on a Melonslab server; they were not measured under Docker.

Before you start

You need:

  • a server set up as in the Docker guide, with Caddy running;
  • an A record and an AAAA record for analytics.example.com pointing at your server;
  • a website to measure, here www.example.com.

Matomo recommends 2 CPU cores and 2 GB of memory for up to 100,000 pageviews a month. The examples use analytics.example.com for Matomo and 203.0.113.10 for your server's IPv4 address. Replace them throughout.

1. Create the user

As root:

useradd -m -s /bin/bash matomo
loginctl enable-linger matomo
uid=$(id -u matomo)

Everything up to step 6 runs as matomo.

2. Create the secret

The passwords are generated with the Compose file in the next step and kept in a 0600 file under the app directory.

This is the password of Matomo's database account. Docker keeps it, not the files below. MariaDB gets it when it creates the database, and the installer in step 4 fills it in by itself, then writes it to Matomo's settings file, config.ini.php, as Matomo has no other place to read it from.

3. Define the Compose project

Create a Compose file in the app's directory. It uses the same images, ports, volumes, environment and restart policy as the Podman guide:

mkdir -p /home/matomo/matomo
cat > /home/matomo/matomo/compose.yaml <<'YAML'
services:
  db:
    image: docker.io/library/mariadb:12.3
    command: --max-allowed-packet=64M
    volumes:
      - db:/var/lib/mysql
    environment:
      MARIADB_DATABASE: matomo
      MARIADB_USER: matomo
      MARIADB_RANDOM_ROOT_PASSWORD: "1"
      MARIADB_AUTO_UPGRADE: "1"
    env_file: matomo.env
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
    restart: always
  app:
    image: docker.io/library/matomo:5.14.0-apache
    ports:
      - "127.0.0.1:8145:80"
    volumes:
      - /home/matomo/matomo/config:/var/www/html/config
      - /home/matomo/matomo/misc:/var/www/html/misc
      - /home/matomo/matomo/custom-plugins:/var/www/html/custom-plugins
    environment:
      MATOMO_PLUGIN_DIRS: /var/www/html/custom-plugins/;custom-plugins
      MATOMO_PLUGIN_COPY_DIR: /var/www/html/custom-plugins/
      MATOMO_DATABASE_HOST: 127.0.0.1
      MATOMO_DATABASE_USERNAME: matomo
      MATOMO_DATABASE_DBNAME: matomo
    env_file: matomo.env
    healthcheck:
      test: ["CMD", "curl", "-fs", "-o", "/dev/null", "http://127.0.0.1/matomo.php"]
      interval: 10s
    restart: always
volumes:
  db:
YAML
umask 077
dbpw=$(openssl rand -hex 24)
printf 'MARIADB_PASSWORD=%s\nMATOMO_DATABASE_PASSWORD=%s\n' "$dbpw" "$dbpw" > /home/matomo/matomo/matomo.env
unset dbpw
chmod 600 /home/matomo/matomo/matomo.env
chown -R matomo:matomo /home/matomo/matomo
uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/matomo/matomo && docker compose up -d"

Use the weekly docker-update.service/docker-update.timer from the rootless Docker guide instead of Podman's auto-update timer. It runs docker compose pull and docker compose up -d in the app directory each Sunday. Set it up once for matomo as shown there; it covers every Compose app in that user's home.

The first start downloads about 960 MB of images; on our server it took 70 seconds. Matomo is ready when this prints 200:

curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8145/

4. Install over an SSH tunnel

Until the installer has finished, anyone who reaches Matomo can run it and create the super user, the account that controls everything. So do it before Caddy makes Matomo public. From your own computer, open an SSH tunnel to the server:

ssh -L 8145:127.0.0.1:8145 root@203.0.113.10

Open http://localhost:8145 in your browser and choose Next through these pages:

  1. System Check lists what Matomo needs. Everything has a green tick except Forced SSL Connection, which step 6 fixes.
  2. Database Setup is already filled in from the pod's settings. Set Database Engine to MariaDB and leave the rest.
  3. Superuser: choose a Superuser login, a long Password and your Email. Leave the two boxes below unticked: they sign you up for email from Matomo.
  4. Set up a Website: the Website URL field fills in https:// when you click it. Type the rest, www.example.com. Set Website timezone to Sweden, and Ecommerce to Ecommerce enabled if your site sells online.
  5. JavaScript Tracking Code: skip this code, as it points at localhost. You get the right one in step 9.
  6. Congratulations: leave both boxes ticked. Automatically configure geolocation using a dbip database downloads DB-IP's free city database, about 130 MB, so Matomo can show countries and cities. Anonymize the last byte(s) of visitors IP addresses shortens addresses before they are stored. Choose Continue to Matomo.

The login page appears. Matomo now refuses to run the installer again. Close the tunnel with exit.

5. Trust Caddy

Matomo only accepts requests for host names it knows, and it needs to be told that Caddy passes on the visitor's address and that visitors use HTTPS. As matomo:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
docker compose exec -u www-data app ./console config:set \
  'General.trusted_hosts[]="analytics.example.com"' \
  'General.proxy_client_headers[]="HTTP_X_FORWARDED_FOR"' \
  'General.proxy_scheme_headers[]="HTTP_X_FORWARDED_PROTO"'
SH

Inside the pod, every request comes from Caddy, at the server's own address. Caddy puts the visitor's real address in X-Forwarded-For, and replaces any value a visitor sends there. Without the second line, every visit has the address 203.0.113.10, and the same location. config:set writes to config.ini.php, and the change takes effect at once.

6. Put Caddy in front

Go back to root with exit, switch to runuser -u caddy -- /bin/bash, and add this block at the end of ~/Caddyfile:

analytics.example.com {
    reverse_proxy 127.0.0.1:8145
}

Restart Caddy with runuser -u caddy -- env HOME=/home/caddy XDG_RUNTIME_DIR=/run/user/$(id -u caddy) DOCKER_HOST=unix:///run/user/$(id -u caddy)/docker.sock PATH=/usr/bin:/bin bash -lc 'cd /home/caddy/caddy && docker compose restart caddy', open https://analytics.example.com, and log in. Then, as matomo again (with the Compose commands from step 1), make Matomo use HTTPS only:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
docker compose exec -u www-data app ./console config:set 'General.force_ssl=1'
SH

7. Build reports in the background

Matomo stores each visit as raw data, and builds its reports, the numbers you see, from it in a step it calls archiving. By default, a report is built when someone opens it in the browser. That makes the dashboard slow as visits grow, and Matomo recommends building them on a schedule instead. Switch off archiving in the browser:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
docker compose exec -u www-data app ./console config:set \
  'General.enable_browser_archiving_triggering=0' \
  'General.browser_archiving_disabled_enforce=1'
SH

Then run the archiving every hour. Create ~/.config/systemd/user/matomo-archive.service:

[Unit]
Description=Build Matomo's reports

[Service]
Type=oneshot
Environment=DOCKER_HOST=unix:///run/user/%U/docker.sock
ExecStart=/usr/bin/docker compose -f /home/matomo/matomo/compose.yaml exec -u www-data app ./console core:archive --matomo-domain=https://analytics.example.com

And ~/.config/systemd/user/matomo-archive.timer:

[Unit]
Description=Build Matomo's reports every hour

[Timer]
OnCalendar=hourly
RandomizedDelaySec=5min

[Install]
WantedBy=timers.target
systemctl --user enable --now matomo-archive.timer
systemctl --user start matomo-archive.service

The same run also does Matomo's scheduled tasks, such as sending email reports and deleting old data. For our 1,200 test visits it took 10 seconds. Reports for today are at most an hour old; the Visits Log and Real-time views show visits at once. journalctl --user -u matomo-archive shows how each run went.

8. Choose your privacy settings

Matomo can collect a lot, and the defaults are not the strictest. Open the gear icon, Administration, then Privacy, Anonymize data:

  • Anonymize Visitors' IP addresses is already on, with 2 byte(s), from step 4. Matomo stores 198.51.0.0 instead of 198.51.100.7. Also use the Anonymized IP addresses when enriching visits is No by default: the location is looked up from the full address before it is shortened, which gives cities. With Yes, the location is less precise.
  • Turn on Force tracking without cookies, and choose Save. Matomo then changes matomo.js so that no tracker sets cookies, and ignores tracking cookies on the server. Without it, Matomo sets _pk_id, kept for 13 months, _pk_ses and _pk_ref. Without cookies, a visitor who returns on another day counts as a new visitor.
  • Under Regularly delete old raw data, tick Regularly delete old raw data from the database, set Delete logs older than (days) to how long you need the details of each visit, such as 180, and choose Save. Matomo asks for your password to confirm changes on this page. The reports stay; only the visit log and the raw data behind it go. Matomo keeps raw data forever by default.

Then Privacy, Users opt-out:

  • HTML code to embed on your website gives you a few lines to put on your privacy page. They show a tick box, in the visitor's language, which stores an opt-out in the visitor's browser when it is unticked. Older Matomo versions offered an iframe for this; Matomo 5 uses this script instead.
  • Under Support Do Not Track preference, choose Enable Do Not Track support if you want to respect it. Matomo calls the feature deprecated, as few browsers still send the header, but it worked in 5.14.0: a visit with DNT: 1 was not recorded.

What this means for consent, as we read the sources, checked 2026-10-14. It is not legal advice: ask your data protection officer or a lawyer about your own site.

  • In Sweden, the rule on cookies is in the Electronic Communications Act, supervised by PTS. As a main rule, cookies may not be stored without consent, except those needed for a service the visitor asked for, and PTS names collecting statistics as something that does not count as needed (PTS, updated 2024-05-14). With cookies on, Matomo needs consent like any other analytics.
  • Without cookies, the question is not settled by that alone. The European Data Protection Board's guidelines on the same rule, adopted 7 October 2024, say that a tracking request sent by JavaScript from the visitor's browser can also fall under it, and that this "does not systematically mean that consent needs to be collected" (EDPB Guidelines 2/2023).
  • The GDPR still applies to what Matomo stores: the shortened IP address, the browser and the pages are personal data for as long as they can be tied to a person. Shortened addresses, no cookies and deleting raw data make that smaller.
  • IMY's decisions against Tele2, CDON, Coop and Dagens industri on 3 July 2023 were about sending data to Google in the United States (IMY). With Matomo on your own server in Sweden, that transfer does not happen.

Matomo also has a page for France's data protection authority, CNIL, which lets sites skip consent for analytics on certain conditions: Privacy, Compliance checks your settings against them. That is French guidance, not and our test site met only some of the conditions.

9. Track your website

Under Administration, Websites, Tracking Code, Matomo shows the code for your site. Paste it into the <head> of every page:

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//analytics.example.com/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

If the site is served by the same Caddy, a static site needs no more than a block such as www.example.com { root * /srv/www; file_server }, with the site's folder mounted into Caddy's container, as the Plausible guide shows.

Open your site in a browser, then Visitors, Visits Log in Matomo. The visit is there at once, with your address shortened, your city, browser and the pages you opened. What else Matomo tracks, with what we tested:

  • Campaigns. Links with utm_source, utm_medium and utm_campaign, such as https://www.example.com/?utm_source=linkedin&utm_medium=social&utm_campaign=autumn, show up under Acquisition, Campaigns. Matomo's own mtm_ parameters work the same.
  • Goals. Under Goals, Manage Goals, Add a new goal, a goal is reached when, for example, a visitor opens a URL that contains thanks.html, or sends an event. Matomo shows conversions, conversion rate and revenue per goal.
  • Ecommerce. With ecommerce on for the site, your shop's order page adds the items and the order:
<script>
  _paq.push(['addEcommerceItem', 'WA-1', 'Widget A', 'Widgets', 499, 1]);
  _paq.push(['trackEcommerceOrder', 'ORDER-1001', 499, 499, 99.8, 0, 0]);
</script>

That is SKU, name, category, price and quantity, then order ID, total, subtotal, tax, shipping and discount. Ecommerce then shows orders, revenue and products. Set the site's Currency to Swedish Krona under Websites, Manage.

  • Site search. A search page with the term in q, query, s, search or keyword in its address shows the terms under Behaviour, Site Search, with no setup.
  • Events. A button can send _paq.push(['trackEvent', 'Video', 'Play', 'Intro']), which shows under Behaviour, Events.

Matomo drops visits from known bots. We sent our simulated visits through the Tracking HTTP API, with a token so they could carry addresses and times of their own; a browser with the snippet above needs nothing more.

10. Give others view-only access

Under Administration, System, Users, choose Invite a new user, enter a Username and Email, pick your website under First website permission, and choose Invite user. The new user gets the View role for that site. Matomo sends an invitation, valid for 7 days, with a link where the user sets a password. A user with View sees every report of that site, but no settings: our test user got "You can't access this resource as it requires admin access" on the settings pages.

Until email works (step 11), the user's row has Resend/Copy Invite Link, which gives you the link to send another way. Write also lets a user add goals and annotations, and Admin change the site's settings and its users. Each user can turn on two-factor authentication under Personal, Security.

11. Email and scheduled reports

Matomo sends email for invitations, password resets, scheduled reports and notices about new versions. This guide does not set up a mail server, and without one:

  • invitations are saved but never arrive, so use Resend/Copy Invite Link;
  • Lost your password? on the login page says "Could not instantiate mail function";
  • scheduled reports are not delivered.

To send through your email provider, store the SMTP password as a secret, as matomo:

The passwords are generated with the Compose file in the next step and kept in a 0600 file under the app directory.

Then give Matomo the settings, with your own server, account and sender:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
docker compose exec -u www-data app ./console config:set \
  'mail.transport="smtp"' 'mail.host="mail.example.com"' 'mail.port=587' \
  'mail.encryption="tls"' 'mail.type="Login"' 'mail.username="analytics@example.com"' \
  'General.noreply_email_address="analytics@example.com"' 'General.noreply_email_name="Matomo"'
docker compose exec -u www-data app ./console config:set \
  "mail.password=\"$(sed -n 's/^MATOMO_SMTP_PASSWORD=//p' /home/matomo/matomo/matomo.env)\"" > /dev/null
docker compose exec -u www-data app ./console core:test-email you@example.com
SH

tls on port 587 uses STARTTLS; for port 465, use mail.port=465 and mail.encryption="ssl". Like the database password, Matomo keeps the SMTP password in config.ini.php, and the > /dev/null keeps it off your screen. We tested these settings against a mail catcher on the server, with a login, not against a real provider.

For a weekly report, open Administration, Personal, Schedule Reports, and choose Create and schedule a report: give it a Description, set Report Schedule to Weekly, add other recipients under Also send the report to these emails, tick the reports you want, such as the visits overview, channels, goals and countries, and choose Create Report. The hourly run from step 7 sends it. In our test, the report arrived as an HTML email to both recipients.

12. Use Matomo in Swedish

Matomo comes translated into Swedish. Each user picks Svenska under Personal, Settings, Language, and Save. Users who have not picked a language get the one their browser asks for.

13. Import from Google Analytics

Matomo's free plugin Google Analytics Importer copies your old reports from Google Analytics 4 into Matomo, so that your history does not start from zero. Install it, as matomo:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
docker compose exec -u www-data app ./console plugin:install-or-update GoogleAnalyticsImporter
docker compose exec -u www-data app ./console plugin:activate GoogleAnalyticsImporter
SH

It appears under Administration, System, Google Analytics Import. To use it, you create a project in Google Cloud, switch on the Google Analytics Data API and Admin API, and make an OAuth client of the type Web application, whose settings file you upload there (Matomo's guide). It imports the reports, not the single visits: the Visits Log, segments and ecommerce logs stay empty for the imported period, and goals come without revenue (Matomo). We installed version 5.2.4 and saw its upload page, but did not import anything, as that needs a Google account with Analytics data.

14. Paid plugins

Matomo's Marketplace, under Administration, Plugins, sells plugins that are part of Matomo Cloud but not of the free version. Until step 15, Matomo also shows them as menu items that lead to the shop, such as Funnels, Heatmaps and Session Recordings, even to view-only users. Prices from the Marketplace on 2026-10-14, per year, for up to 4 users, before VAT:

PluginPrice
Heatmap & Session Recording€219
A/B Testing€219
Custom Reports€219
Funnels€199
Media Analytics€179
Advertising Conversion Export€169
Crash Analytics€153
Form Analytics€149
Users Flow, Cohorts, Multi Channel Conversion Attribution, SEO Web Vitals€89 each
Activity Log€39
Login SAML, for single sign-on€2,219, any number of users

Bundles start at €2,750 a year for 9 plugins and up to 4 users. We tested none of them. Free plugins, such as the Google Analytics importer and Marketing Campaigns Reporting, install as in step 13.

15. Turn off outside connections

We captured the server's DNS lookups and outgoing connections while Matomo started, showed the dashboard and the Marketplace, and ran its scheduled tasks. It contacted:

  • api.matomo.org, to check for a new version, which then shows as New Update at the top;
  • plugins.matomo.org, the Marketplace, for the plugin list, the paid-plugin menu items and plugin updates;
  • matomo.org, for the news feed in the dashboard;
  • raw.githubusercontent.com, for updated lists of referrer spam, search engines and social networks;
  • download.db-ip.com, for a new location database once a month;
  • the address of your own website, which Matomo looked up by name; we did not find out which feature does it.

Each of them learns your server's address and when it asked, and none of them gets visitor data. To switch all of them off, as matomo:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
docker compose exec -u www-data app ./console config:set 'General.enable_internet_features=0'
SH

In a second capture, Matomo made no outside connections at all, the paid-plugin menu items were gone, and the Marketplace said it needs an internet connection. To install a plugin later, set the value to 1 for a moment. You then also watch for new versions yourself, as step 17 explains.

The location database no longer updates by itself either. DB-IP publishes a new one each month, under the Creative Commons Attribution 4.0 licence, which asks that you credit DB-IP if you show its data, such as with a link to https://db-ip.com on pages that show visitors' locations. To update it every month, create ~/geoip-update.sh:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
#!/bin/sh
# Downloads this month's DB-IP city database for Matomo.
set -e
DOCKER_HOST=unix:///run/user/$(id -u matomo)/docker.sock docker compose -f /home/matomo/matomo/compose.yaml exec -u www-data app sh -c 'curl -fsS https://download.db-ip.com/free/dbip-city-lite-$(date +%Y-%m).mmdb.gz | gunzip > misc/DBIP-City.mmdb.new && mv misc/DBIP-City.mmdb.new misc/DBIP-City.mmdb'
SH

Then ~/.config/systemd/user/matomo-geoip.service:

[Unit]
Description=Update Matomo's GeoIP database

[Service]
Type=oneshot
Environment=DOCKER_HOST=unix:///run/user/%U/docker.sock
ExecStart=%h/geoip-update.sh

And ~/.config/systemd/user/matomo-geoip.timer:

[Unit]
Description=Update Matomo's GeoIP database every month

[Timer]
OnCalendar=*-*-05 04:00
Persistent=true

[Install]
WantedBy=timers.target
chmod 700 ~/geoip-update.sh
systemctl --user enable --now matomo-geoip.timer
systemctl --user start matomo-geoip.service

MaxMind's GeoLite2 is the other free database Matomo can use, under Administration, System, Geolocation. It needs a MaxMind account and licence key, and its licence asks you to keep it up to date. We did not test it.

16. Back up

Matomo keeps the visits, reports, users and settings of each site in MariaDB, and its own settings, with the database password and the salt that its logins depend on, in config.ini.php. As matomo, create ~/backup.sh:

uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash <<'SH'
cd /home/matomo/matomo
#!/bin/sh
# Saves Matomo's database, settings, plugins and database password in ~/backup.
set -e
umask 077
mkdir -p ~/backup
cd ~/backup
DOCKER_HOST=unix:///run/user/$(id -u matomo)/docker.sock docker compose -f /home/matomo/matomo/compose.yaml exec -T db sh -c 'mariadb-dump -umatomo -p"$MARIADB_PASSWORD" --single-transaction matomo' | gzip > matomo-db.sql.gz
tar -cf matomo-config.tar -C /home/matomo/matomo config
tar -cf matomo-plugins.tar -C /home/matomo/matomo custom-plugins
sed -n 's/^MARIADB_PASSWORD=//p' /home/matomo/matomo/matomo.env > db-password.txt
SH

Run it every night. Create ~/.config/systemd/user/matomo-backup.service:

[Unit]
Description=Back up Matomo

[Service]
Type=oneshot
Environment=DOCKER_HOST=unix:///run/user/%U/docker.sock
ExecStart=%h/backup.sh

And ~/.config/systemd/user/matomo-backup.timer:

[Unit]
Description=Back up Matomo every night

[Timer]
OnCalendar=*-*-* 03:00
Persistent=true

[Install]
WantedBy=timers.target
chmod 700 ~/backup.sh
systemctl --user enable --now matomo-backup.timer
systemctl --user start matomo-backup.service
ls ~/backup

The dump runs while Matomo keeps working. With our test visits it was 0.5 MB compressed; the plugins took 20 MB, nearly all of it the Google Analytics importer. The location database is left out, as it is downloaded again. Copy ~/backup to another machine, for example with restic, and keep it safe: it holds all your statistics and the passwords.

To restore onto a new server, or for a new matomo user, do step 1 and create the three files from step 3, without starting them. Then, as matomo, with the backup in ~/backup:

The passwords are generated with the Compose file in the next step and kept in a 0600 file under the app directory.

Starting the database starts the whole pod, Matomo too, so stop Matomo before loading the dump. Then set up the timers from steps 7, 15 and 16 again, and run systemctl --user start matomo-geoip.service for the location database. We restored this way after deleting the matomo user and creating it again: all 1,205 visits, the reports, goals, users and the scheduled report came back, and the old passwords and API token worked.

17. Update

MariaDB updates within 12.3 by itself through docker-auto-update.timer. Matomo stays on the version in compose.yaml, as Matomo's database needs updating along with its files. New versions come about once a month; with step 15, Matomo no longer tells you, so follow Matomo's changelog or its releases on GitHub. The image follows Matomo's releases, sometimes later: on 14 October 2026, Matomo 5.14.1 had been out for ten days, while the image was still at 5.14.0.

To update, back up (step 16), change the version, restart and update the database, as matomo:

systemctl --user start matomo-backup.service
cd /home/matomo/matomo
sed -i 's|matomo:5.14.0-apache|matomo:5.14.1-apache|' compose.yaml
uid=$(id -u matomo)
runuser -u matomo -- env HOME=/home/matomo XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/matomo/matomo && docker compose up -d --force-recreate app"
docker compose exec -u www-data app ./console core:update --yes
docker compose down && docker compose up -d

We updated from 5.13.0 to 5.14.0 this way. That version had no database changes, so core:update answered "Everything is already up to date". Plugins from the Marketplace are updated with plugin:install-or-update and the plugin's name. Matomo 6 is in beta; read its notes before you move to it.

Troubleshooting

Every visit has the server's address, or the same location. proxy_client_headers from step 5 is missing. Check docker compose exec -T app grep proxy config/config.ini.php.

"The specified host is not valid" or a warning about an untrusted hostname. The address in your browser is not in trusted_hosts. Add it as in step 5.

Reports stay empty or old, while the Visits Log has visits. The archiving has not run. Check systemctl --user list-timers and journalctl --user -u matomo-archive, as matomo.

Visitors get _pk_ cookies, although cookies are off. matomo.js is the one from the image. Run docker compose exec -u www-data app ./console custom-matomo-js:update, and run the two console commands from the start of step 3 again.

Diagnostics says "Directory to delete: custom-plugins". Matomo's file check does not know the plugin folder from step 3. Leave it: it holds your plugins.

Matomo shows the installer again. The config directory is empty, for example after a restore without step 16's archive import. Do not run the installer on a server that can be reached from the internet; restore the backup instead, or close the port in Caddy until you are done.

Run it on your own server

SSD RAID 1 · ECC DDR4 · 10 Gbit

VC-P Alloy

€8.99/mo

vCPU
2
Memory
8 GB
Storage
60 GB
Transfer
10 TB
Performance
SSD · RAID 1
  • Full root access
  • Native /64 IPv6
  • RAID-protected storage
  • Malmö, Sweden
  • Month to month, no lock-in
  • 7-day money-back guarantee
All guides