Deploy Matomo
Matomo 5 web analytics with MySQL, private auto-install and hourly reports
MySQL
Just deployed
/var/lib/mysql
Matomo
Just deployed
/var/www/html
Deploy and Host Matomo on Railway
Matomo is an open-source web analytics platform and a self-hosted alternative to Google Analytics. It records page views, visitors, referrers, campaigns, goals and e-commerce sales from a JavaScript tracker or its HTTP API, and keeps all of that data in your own database, so you decide how long it is kept and who sees it.
About Hosting Matomo
Matomo is a PHP application backed by MySQL or MariaDB. A normal install needs a web server, a one-time web installer and a cron job that turns raw visits into reports. This template runs all three in one service from the official Apache image, with Railway MySQL over the private network. On first boot it installs Matomo privately with your admin email and a generated password, so the public URL never shows an open installer. Code, config and plugins live on a volume. Browser-triggered archiving is off, and a loop in the same service builds the reports every hour. It reads the visitor IP from Railway's X-Real-IP header.
Common Use Cases
- Privacy-friendly website analytics without sending visitor data to a third party
- Tracking several websites or apps from one dashboard, with goals, funnels and campaign reports
- Replacing Google Analytics where data ownership or GDPR compliance matters
Dependencies for Matomo Hosting
- Matomo 5.14.2 (official
matomo:5.14.2-apacheimage, pinned by digest) with a volume - MySQL 8.4 (
mysql:8.4.13, pinned by digest) with a volume
Deployment Dependencies
- Matomo source code and 5.14.2 changelog
- Official Docker image and Matomo on-premise guides
- Start script used by this template
Implementation Details
- Sign in: open your Railway domain and sign in as
adminwith the password in the Matomo service'sMATOMO_ADMIN_PASSWORDvariable. The admin email and password are read only on the first install, so change the password in Matomo afterwards. - First website: set
MATOMO_FIRST_SITE_URLbefore deploying, or edit "My website" later under Administration > Websites > Manage. Then copy the tracking code from Administration > Websites > Tracking Code into your site. - Reports: they are built by the CLI archiver every hour (
MATOMO_ARCHIVE_INTERVAL, in seconds), so new visits show up in reports after the next run. The Visits Log shows them at once. - Custom domain: add it to Railway, then add it to
trusted_hosts[]inconfig/config.ini.phpon the volume (Administration > System > General settings), or setMATOMO_PUBLIC_DOMAINto it. - Email: set an SMTP server under Administration > System > General settings > Email server settings, so password resets and scheduled reports can be sent.
- Geolocation: Matomo guesses the country from the browser language until you add a geolocation database under Administration > System > Geolocation.
- Upgrades: change the image tag. On the next start the new code is copied onto the volume and database updates run on their own.
Why Deploy Matomo on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Matomo on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
MySQL
mysql:8.4.13Matomo
matomo:5.14.2-apacheMATOMO_ADMIN_EMAIL
MATOMO_FIRST_SITE_URL

