PHP version 7.4 deprecated warning, hence php8.0 not working, running Matomo 4.13.0

We get the following warning in the dashboard:

Warning
The PHP version 7.4 you are using has reached its End of Life (EOL). You are strongly urged to upgrade to a current version, as using this version may expose you to security vulnerabilities and bugs that have been fixed in more recent versions of PHP.

Then installed and switched to php8.0

Website was displaying a blank screen and we got errors in the logs:

2023/01/03 13:29:53 [error] 3185#3185: *789 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Undefined constant PDO::MYSQL_ATTR_FOUND_ROWS in /var/www/html/matomo/core/Tracker/Db/Pdo/Mysql.php:107
Stack trace:
#0 /var/www/html/matomo/core/Tracker/Db.php(286): Piwik\Tracker\Db\Pdo\Mysql->connect()
#1 /var/www/html/matomo/core/Tracker.php(237): Piwik\Tracker\Db::connectPiwikTrackerDb()
#2 /var/www/html/matomo/core/Db.php(52): Piwik\Tracker::getDatabase()
#3 /var/www/html/matomo/core/Tracker.php(197): Piwik\Db::get()
#4 /var/www/html/matomo/core/Tracker/Cache.php(109): Piwik\Tracker::initCorePiwikInTrackerMode()
#5 /var/www/html/matomo/core/Tracker/Cache.php(89): Piwik\Tracker\Cache::updateCacheWebsiteAttributes()
#6 /var/www/html/matomo/core/Tracker/Request.php(615): Piwik\Tracker\Cache::getCacheWebsiteAttributes()
#7 /var/www/html/matomo/core/Tracker/Request.php(596): Piwik\Tracker\Request->getIdSite()
#8 /var/www/html/matomo/core/Tracker/Request.php(96): Piwik\Tracker\Request->getIdSiteIfExists()

Had to go back to php7-4 for the website to run properly again.

Please advise how to solve this.

Also tried with php8.1 and php8.2, now I get a blank screen, please help.

To avoid “PIWIK” errors and other errors once logged into the GUI:

GD > 2.x + FreeType (graphics) GD > 2.x + FreeType (graphics)
The sparklines (small graphs) and image graphs (in the Matomo mobile app and email reports) will not work.
Other extensions json
libxml
dom
You should turn on the “dom” extension (e.g., install the “php-dom” and/or “php-xml” package).
SimpleXML
You should enable the “SimpleXML” extension (e.g., install the “php-simplexml” and/or “php-xml” package).
openssl

SOLUTION:

install the required dependencies

# apt-get install software-properties-common gnupg2 -y

add the PHP repository

# add-apt-repository ppa:ondrej/php

update the repository

# apt-get update -y

Install new php versions

apt install php8.2-dom php8.2-xml php8.2-gd php8.2*-fpm* php8.2*-pdo* -y

Make sure to change all cgi php entries in matomo.conf to the new version:

fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; #replace with the path to your PHP socket file

Disable all older php versions e.g.:
systemctl stop php7.4.service
systemctl disable php7.4.service

Restart the webserver:
service nginx restart

First, check the current version of command-line PHP running the following command:

# php -v

Get all php information:

# php -i