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