Data Whimsy
  • Home
  • What is Matomo
  • Contact
  • Custom Reports
  • Connect Matomo to other software
  • CLI API etc
  • Matomo Tag Manager Simple Guide
  • Lyn Only
  • Troubleshooting + Deploying Matomo
  • Weird Data
  • Why is data in Matomo giving different numbers than Google Analytics
  • The Dashboard
  • Moving the Data
  • Book Club Forum

Checking the PHP version in Matomo

2/7/2024

0 Comments

 
Is PHP installed?
sudo apt update
sudo apt install php

There are two!
Matomo runs two PHPs. One is on the Apache server for the Matomo backend. The other is the PHP for the CLI, which executes the core:archive command

PART ONE: JUST CHECKING THE SERVER PHP WHERE REPORTS AND TRACKING HAPPEN
Check memory and the version of PHP in the web server which serves your Matomo Interface
First, make a serveable phpinfo(); page. I placed mine at https://littlefurnace.com/foobarbaz.php
Then serve that page, in the browser. Or from CURL. 
In Curl: curl https://littlefurnace.com/foobarbaz.php | grep memory

In your browser, the classic pink and blue PHP information page will appear. 

This will have important information about the memory_limit, the path to where the configuration files are, and the PHP version you are running.


PART TWO: JUST CHECKING THE CLI ENVIRONMENT PHP, WHERE CORE:ARCHIVE AND OTHER CONSOLE COMMANDS ARE EXECUTED

Check memory and the version of PHP in CLI (for Matomo core:archive) 
IMPORTANT The core:archive of Matomo uses the PHP settings of CLI, not of the web server.
php -i | grep memory_limit
To find the path to the config file where you can edit things like  memory_limit
php -i | grep -i config

Example in my Matomo CLI environment
This:
php -i | grep -i config
Returns this:
Loaded Configuration File => /etc/php/8.1/cli/php.ini
So edit that file to look like this:
memory_limit=6G

Is PHP enabled for Apache?
sudo apt install libapache2-mod-php
(restart Apache)
sudo systemctl restart apache2

Configuration
Check the PHP configuration file (php.ini) to ensure that the disable_functions directive does not include any module that you need!
Find the php.ini
php -i | grep php.ini
Then, edit the php.ini file
And restart server
sudo systemctl restart apache2

Increase PHP memory in Matomo
A typical Matomo error is
Allowed memory size of 4294967296 bytes exhausted

Typical steps to fix this error:
Find the php.ini
php -i | grep php.ini
Then, edit this line in the php.ini file
memory_limit=8G
And restart server
sudo systemctl restart apache2

(Or, if you want to experiment on-the-fly with benchmarking the performance, you can actually override the memory limit directly, including in the crontab, using an option
such as: php -d memory_limit=2G /var/www/html/console core:archive )

A less common, laborious, alternative solution to prevent the php process from using too much memory is only process a specific number of reports at a time in order. We can achieve this by using a combination of --force-periods and --force-date-range in the core:archive task to process only a few specific reports for each core:archive run: For example: php path/to/matomo/console core:archive --force-idsite=13 --force-periods=day,week,month --force-date-range=2021-01-01,2021-01-31 And then repeat this process for each month that the reports were invalidated for.



0 Comments



Leave a Reply.

    Troubleshooting + Deploying Matomo

    Archives

    December 2024
    July 2024
    April 2024
    March 2024
    February 2024
    November 2023
    October 2023

    Categories

    All

Powered by Create your own unique website with customizable templates.
  • Home
  • What is Matomo
  • Contact
  • Custom Reports
  • Connect Matomo to other software
  • CLI API etc
  • Matomo Tag Manager Simple Guide
  • Lyn Only
  • Troubleshooting + Deploying Matomo
  • Weird Data
  • Why is data in Matomo giving different numbers than Google Analytics
  • The Dashboard
  • Moving the Data
  • Book Club Forum