Matomo
Overview
Matomo is the leading open-source web analytics platform and a privacy-respecting alternative to Google Analytics. It gives you 100 percent data ownership, accurate visitor and behaviour reports, real-time analytics, goal and ecommerce tracking, heatmaps and session recordings, and full GDPR controls, all hosted on your own infrastructure.
The SecureAnyCloud image installs Matomo 5.11.2 on a full LAMP stack from the Ubuntu 24.04 repositories (nginx, PHP 8.3-FPM and MariaDB). It runs the entire headless install at build time, so there is no web wizard. On the first boot of every VM, it rotates the database password, the application salt and the administrator account.
What you get:
- Matomo 5.11.2 served on port 80 by nginx via the PHP 8.3-FPM FastCGI socket
- MariaDB on loopback with its data directory on a dedicated Azure data disk
- A dedicated Azure data disk at
/var/lib/matomofor the MariaDB database and Matomo configuration - Per-VM database credentials, application salt and a unique administrator account generated on first boot
nginx.service,php8.3-fpm.serviceandmariadb.serviceas systemd units, enabled and active- 24/7 SecureAnyCloud support
Prerequisites
You need an active Azure subscription, an SSH key pair, and a VNet with a subnet in the target region.
Standard_B2ms (2 vCPU / 8 GiB RAM) is a good starting point.
Configure the network security group (NSG) to allow inbound 22/tcp from your management network and 80/tcp for the Matomo web interface. For public exposure, front the interface with TLS (see Enabling HTTPS).
Step 1 - Deploy from the Azure Marketplace
Sign in to the Azure Portal, choose Create a resource, search the Marketplace for Matomo by SecureAnyCloud, and select Create.
On the Basics tab, pick your subscription, resource group, region and size. Under Administrator account, choose SSH public key and paste your key. Under Inbound port rules, allow SSH (22) and HTTP (80).
Review the dedicated data disk on the Disks tab, then select Review + create and Create.
Step 2 - Deploy from the Azure CLI
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:matomo-ubuntu-24-04:default:latest
az vm create \
--resource-group <your-rg> \
--name matomo \
--image sac1647283583153:matomo-ubuntu-24-04:default:latest \
--size Standard_B2ms \
--admin-username azureuser \
--ssh-key-values ~/.ssh/id_ed25519.pub \
--vnet-name <your-vnet> --subnet <your-subnet> \
--public-ip-sku Standard
az vm open-port --resource-group <your-rg> --name matomo --port 80 --priority 1010Step 3 - Connect to your VM
ssh azureuser@<vm-public-ip>Step 4 - Confirm the LAMP stack is running
On first boot, Matomo regenerates its database credentials and application salt, recreates a clean analytics database, creates the administrator account and starts the stack. Check the three services:
systemctl is-active nginx php8.3-fpm mariadbAll three report active.
Confirm the component versions and that the Matomo tracker endpoint answers:
php -v | head -1 mariadb --version curl -s -o /dev/null -w 'HTTP %{http_code}\n' http://127.0.0.1/matomo.phpThe tracker endpoint returns HTTP 200.
Step 5 - Retrieve the administrator password
The administrator account is unique to your VM and is generated on first boot. Read it as root:
sudo cat /root/matomo-credentials.txtThe file contains the login (admin), the email (admin@sac.local) and a unique password. After your first sign-in, change the email and password from the admin panel.
Step 6 - Sign in to Matomo
Browse to http://<vm-public-ip>/ and sign in with admin and the password from the credentials file.
Step 7 - Add your first website
On first sign-in, Matomo asks you to add the first website you want to track. Enter a name and the site URL, then save.
Matomo then shows the JavaScript tracking code. Paste it into the <head> of every page on your website, or install it through your tag manager or CMS plugin. Within minutes, the reports begin to populate.
Step 8 - Explore the reporting dashboard
The dashboard shows visits in real time, visits over time and a customisable set of widgets.
The Visitors section breaks down visits, unique visitors, pageviews, locations, devices and software.
Step 9 - Administration settings
The Administration area (the gear icon) holds system settings, user management, geolocation, archiving and privacy controls.
Data on the dedicated data disk
The MariaDB data directory (/var/lib/matomo/mysql) and the Matomo configuration and cache (/var/lib/matomo/matomo-config, /var/lib/matomo/matomo-tmp) live on a dedicated Azure data disk mounted at /var/lib/matomo. This keeps all of your analytics data and configuration on a managed disk that you can snapshot, resize and back up independently of the OS disk.
df -h /var/lib/matomo | tail -1Enabling HTTPS
For production, put Matomo behind TLS. The simplest approach is a free Let's Encrypt certificate from Certbot, once you have a DNS name that points at the VM:
sudo snap install --classic certbot
sudo ln -sf /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx -d your-domain.example.comCertbot edits the nginx site to serve HTTPS and sets up automatic renewal. After enabling TLS, add your HTTPS hostname to [General] trusted_hosts[] in /var/lib/matomo/matomo-config/config.ini.php and set force_ssl = 1. Then run sudo systemctl reload nginx.
Maintenance
Matomo periodically ships new releases. To upgrade, follow the official Matomo update procedure. Replace the application files under /var/www/matomo, keeping config/ and tmp/, which are symlinked to the data disk. Then run sudo -u www-data php /var/www/matomo/console core:update --yes.
The OS continues to receive unattended security updates. The MariaDB database and Matomo configuration persist on the data disk across reboots and upgrades.
Support
This image is maintained by SecureAnyCloud with 24/7 support. Matomo is open-source software licensed under the GPL-3.0. "Matomo" is a trademark of InnoCraft Ltd, and SecureAnyCloud is not affiliated with or endorsed by InnoCraft. For help with this image, contact sales@secureanycloud.com.
Deploy on Azure
Launch Matomo on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.
View this image
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com
Overview
Matomo is the leading open-source, privacy-first web analytics platform and a fully featured self-hosted alternative to Google Analytics. It keeps 100% ownership of your data on your own server. This image delivers Matomo as a production LAMP application, so a complete analytics platform is running within minutes of launch.
What you get:
- Matomo as a PHP 8.3 application under php-fpm, served by nginx on port 80
- A MariaDB database that stores every visit, action, goal and report
- Application code under
/var/www/matomo, and the analytics database at/var/lib/mysql, which is a dedicated, independently resizable EBS data volume that survives instance replacement - Systemd management of MariaDB, the PHP FastCGI workers and nginx, which start on boot and restart on failure
- Matomo's own administrator login. On the first boot of every deployed instance, a one-shot service generates a fresh MariaDB password and a fresh administrator password, both unique to that instance, creates the Matomo superuser, and pins the dashboard to the instance address. Two instances launched from the same Amazon Machine Image never share credentials.
- The administrator password in
/root/matomo-credentials.txtwith mode 0600, so that only the root user can read it
Prerequisites
Before you deploy this image, you need:
- An Amazon Web Services account where you can launch EC2 instances
- IAM permissions to launch instances, create security groups and subscribe to AWS Marketplace products
- An EC2 key pair in the target Region for SSH access to the instance
- A VPC and subnet in the target Region, with a security group that allows inbound port 22 from your management network and port 80 for the Matomo dashboard
- The AWS CLI (version 2) installed locally, if you plan to deploy from the command line
Launch the instance from the AWS Marketplace
Sign in to the AWS Management Console, open the EC2 service, and select Launch instance. Under Application and OS Images, choose AWS Marketplace AMIs and search for Matomo. Select the SecureAnyCloud listing, choose Select, then choose Continue on the subscription summary.
Pick an instance type of t3.large or larger. Choose your EC2 key pair under Key pair (login).
Under Network settings, select your VPC and subnet. Create or select a security group that opens port 22 from your management network and port 80 for the Matomo dashboard. Leave the root volume at the default size or larger.
Select Launch instance. First-boot initialisation takes a few seconds after the instance state becomes Running and the status checks pass. During this time, the per-instance database and administrator passwords are generated and the Matomo schema is created.
Launch the instance from the AWS CLI
Run the command below to launch an instance from the SecureAnyCloud Matomo Marketplace AMI into an existing subnet and security group. Replace the values in angle brackets:
- <ami-id>: the AMI ID shown on the Marketplace listing
- <key-name>: your EC2 key pair name
- <subnet-id>: your subnet ID
- <security-group-id>: a security group that opens ports 22 and 80 as described above
aws ec2 run-instances \
--image-id <ami-id> \
--instance-type t3.large \
--key-name <key-name> \
--subnet-id <subnet-id> \
--security-group-ids <security-group-id> \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=matomo}]'When the instance reaches the Running state and its status checks pass, note its public IP address or DNS name from the EC2 console or with aws ec2 describe-instances.
Connect to your instance
Connect over SSH using your key pair and the login user for your operating system variant. For Ubuntu 24.04, the user is ubuntu.
ssh -i <key-name>.pem ubuntu@<public-ip>Retrieve the administrator password
The Matomo administrator password is unique to your instance and was generated on first boot. Read it as root:
sudo cat /root/matomo-credentials.txtThe file lists the dashboard URL, the administrator login (admin), the administrator email and the generated password. Keep this password somewhere safe.
Sign In to the Matomo Dashboard
The Matomo dashboard is served on port 80 by nginx through php-fpm. In a browser, go to:
http://<instance-public-ip>/Sign in as admin with the password from the credentials file. You land on the Matomo dashboard, where the Visitors overview shows the visits-over-time graph and the headline analytics sparklines.
The Behaviour reports break down page views, entry and exit pages, page titles, downloads and outlinks for every URL, with no data sampling because the data never leaves your server.
Confirm Matomo Is Running
Over SSH, confirm the database, the PHP FastCGI workers and the nginx proxy are active and that the dashboard answers:
sudo systemctl is-active mariadb php8.3-fpm nginx curl -s -o /dev/null -w 'matomo.php HTTP %{http_code}\n' http://127.0.0.1/matomo.phpYou should see all three services reported as active and the Matomo tracking endpoint answering 200. MariaDB listens on loopback only and is never exposed publicly; only nginx on port 80 is reachable from outside the instance.
Set Your Trusted Host or Custom Domain
Matomo rejects any request whose HTTP Host header is not in its trusted hosts list. First boot already pins your instance public IP, which is why the dashboard is reachable immediately. You can confirm the current trusted hosts at any time:
sudo grep -E 'trusted_hosts|enable_trusted_host_check' /var/www/matomo/config/config.ini.phpWhen you put Matomo behind a custom domain or a load balancer, add that hostname to the trusted hosts list. The simplest way is in the dashboard under Administration, then System, then General settings, where Matomo lists the trusted hostnames and lets you add your own. You can also add it from the command line with the bundled console, substituting your own hostname for analytics.example.com: sudo -u www-data php /var/www/matomo/console config:set --section=General --key='trusted_hosts[]' --value='analytics.example.com', then reload php-fpm with sudo systemctl reload php8.3-fpm so the change takes effect.
After adding a domain, point its DNS A record at the instance public IP and browse to http://analytics.example.com/.
Add a Website and Install the Tracking Code
To start collecting analytics, add the website you want to measure. In the dashboard, open Administration (the cog icon), then Websites and Manage. Select Add a new measurable, give it a name and its URL, set the time zone and currency, and save.
Next to each website, choose View Tracking code to copy the JavaScript snippet Matomo generates. Paste that snippet into the <head> of every page you want to track, or install it through your tag manager or CMS plugin. Matomo also offers a Matomo Tag Manager and ready made integrations for common platforms. As soon as the tracking code runs on your site, visits, page views and events appear in the Visitors and Behaviour reports in real time.
Use the Reporting API
Every report in Matomo is also available programmatically through the Reporting API on the same port 80. Create a per user API token (a token_auth) from Administration, then Personal, then Security, under Auth tokens. With a token you can pull any report as JSON, XML or CSV. For example, fetch the Matomo version to confirm API access, replacing <instance-public-ip> and <token>:
http://<instance-public-ip>/index.php?module=API&method=API.getMatomoVersion&format=json&token_auth=<token>Treat API tokens like passwords and scope them to the minimum access each integration needs.
The Data Volume
The Matomo analytics database lives on a dedicated EBS volume mounted at /var/lib/mysql. This keeps the database off the operating system disk and lets you resize or snapshot it independently. Confirm the mount with:
df -h /var/lib/mysqlTo grow the database store, expand the EBS volume in the AWS console, then grow the filesystem on the instance with sudo resize2fs on the underlying device. Because the database is on its own volume, you can snapshot it for backup or detach and reattach it to a replacement instance.
Enable HTTPS
The dashboard is served over plain HTTP on port 80 by nginx. For production use, place it behind TLS. Obtain a certificate for your domain (for example with a managed certificate on an Application Load Balancer in front of the instance, or with Certbot installed on the instance), then configure nginx to listen on 443 with your certificate and proxy to php-fpm exactly as the bundled site does for port 80. Add your domain to the Matomo trusted hosts as shown in Step 7, set force_ssl = 1 in the [General] section of config.ini.php so Matomo issues secure cookies and redirects, and restrict the security group so ports 80 and 443 are reachable only from the networks that need the dashboard.
Backup and Maintenance
Back up Matomo by snapshotting the /var/lib/mysql EBS volume, which captures the entire analytics database, and by keeping a copy of /var/www/matomo/config/config.ini.php, which holds the database credentials, the encryption salt and the trusted hosts. You can also take a logical dump of the database with mysqldump over the loopback socket. Apply operating system security updates with sudo apt-get update && sudo apt-get upgrade and reboot when a new kernel is installed; MariaDB, php-fpm and nginx start automatically on boot. Upgrade Matomo itself from within the dashboard or with sudo -u www-data php /var/www/matomo/console core:update after backing up the database.
Support
This image is published and supported by SecureAnyCloud. Support covers deployment, website and tracking code setup, the Reporting API, user management, GDPR and privacy configuration, database tuning, TLS and scaling. Contact SecureAnyCloud through the support channel listed on the AWS Marketplace listing.
All product and company names are trademarks or registered trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
Deploy on AWS
Launch Matomo on AWS with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com