1# Matomo {#module-services-matomo} 2 3Matomo is a real-time web analytics application. This module configures 4php-fpm as backend for Matomo, optionally configuring an nginx vhost as well. 5 6An automatic setup is not supported by Matomo, so you need to configure Matomo 7itself in the browser-based Matomo setup. 8 9## Database Setup {#module-services-matomo-database-setup} 10 11You also need to configure a MariaDB or MySQL database and -user for Matomo 12yourself, and enter those credentials in your browser. You can use 13passwordless database authentication via the UNIX_SOCKET authentication 14plugin with the following SQL commands: 15``` 16# For MariaDB 17INSTALL PLUGIN unix_socket SONAME 'auth_socket'; 18CREATE DATABASE matomo; 19CREATE USER 'matomo'@'localhost' IDENTIFIED WITH unix_socket; 20GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; 21 22# For MySQL 23INSTALL PLUGIN auth_socket SONAME 'auth_socket.so'; 24CREATE DATABASE matomo; 25CREATE USER 'matomo'@'localhost' IDENTIFIED WITH auth_socket; 26GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; 27``` 28Then fill in `matomo` as database user and database name, 29and leave the password field blank. This authentication works by allowing 30only the `matomo` unix user to authenticate as the 31`matomo` database user (without needing a password), but no 32other users. For more information on passwordless login, see 33<https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin/>. 34 35Of course, you can use password based authentication as well, e.g. when the 36database is not on the same host. 37 38## Archive Processing {#module-services-matomo-archive-processing} 39 40This module comes with the systemd service 41`matomo-archive-processing.service` and a timer that 42automatically triggers archive processing every hour. This means that you 43can safely 44[disable browser triggers for Matomo archiving]( 45https://matomo.org/docs/setup-auto-archiving/#disable-browser-triggers-for-matomo-archiving-and-limit-matomo-reports-to-updating-every-hour 46) at 47`Administration > System > General Settings`. 48 49With automatic archive processing, you can now also enable to 50[delete old visitor logs](https://matomo.org/docs/privacy/#step-2-delete-old-visitors-logs) 51at `Administration > System > Privacy`, but make sure that you run `systemctl start 52matomo-archive-processing.service` at least once without errors if 53you have already collected data before, so that the reports get archived 54before the source data gets deleted. 55 56## Backup {#module-services-matomo-backups} 57 58You only need to take backups of your MySQL database and the 59{file}`/var/lib/matomo/config/config.ini.php` file. Use a user 60in the `matomo` group or root to access the file. For more 61information, see 62<https://matomo.org/faq/how-to-install/faq_138/>. 63 64## Issues {#module-services-matomo-issues} 65 66 - Matomo will warn you that the JavaScript tracker is not writable. This is 67 because it's located in the read-only nix store. You can safely ignore 68 this, unless you need a plugin that needs JavaScript tracker access. 69 70## Using other Web Servers than nginx {#module-services-matomo-other-web-servers} 71 72You can use other web servers by forwarding calls for 73{file}`index.php` and {file}`piwik.php` to the 74[`services.phpfpm.pools.<name>.socket`](#opt-services.phpfpm.pools._name_.socket) 75fastcgi unix socket. You can use 76the nginx configuration in the module code as a reference to what else 77should be configured.