| If you have both PHP 7.4 and PHP 8.1 installed on CentOS 7, but you're unsure where PHP 8.1 is located (e.g., for CLI use or configuring services), you can locate it with the following steps: 1. Check Current PHP Versionphp -v
2. Install EPEL and Remi Repositoriessudo yum install epel-release yum-utils -y
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
3. Enable Remi PHP 8 RepositoryFirst, check available PHP modules: yum module list php
Enable PHP 8.1 (or 8.2 if needed — change version accordingly): sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php81
4. Upgrade PHPsudo yum update -y
sudo yum install php php-cli php-common php-fpm php-mysqlnd php-xml php-mbstring php-opcache php-json php-gd php-curl -y
(Add any other PHP extensions your application needs) 5. Verify PHP Versionphp -v
6. Restart Web ServerFor Apache: sudo systemctl restart httpd
For Nginx with PHP-FPM: sudo systemctl restart php-fpm
sudo systemctl restart nginx
In my case, I faced following errors while installing PHP 8.1 Error: Package: php-pecl-redis5-5.3.7-2.el7.remi.7.4.x86_64 (@remi-php74)
Requires: php(api) = 20190902-64
Removing: php-common-7.4.33-15.el7.remi.x86_64 (@remi-php74)
php(api) = 20190902-64
Updated By: php-common-8.1.29-1.el7.remi.x86_64 (remi-php81)
php(api) = 20210902-64
Available: php-common-8.1.28-1.el7.remi.x86_64 (remi-php81)
php(api) = 20210902-64
Error: Package: php-pecl-redis5-5.3.7-2.el7.remi.7.4.x86_64 (@remi-php74)
Requires: php(zend-abi) = 20190902-64
Removing: php-common-7.4.33-15.el7.remi.x86_64 (@remi-php74)
php(zend-abi) = 20190902-64
Updated By: php-common-8.1.29-1.el7.remi.x86_64 (remi-php81)
php(zend-abi) = 20210902-64
Available: php-common-8.1.28-1.el7.remi.x86_64 (remi-php81)
php(zend-abi) = 20210902-64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
And the solution was to remove the PHP 7.4-specific packages such as php-pecl-redis5 before processing with the PHP 8.1 upgrade. Below steps are what I did: 1. Remove the PHP 7.4 Redis extension: sudo yum remove php-pecl-redis5
2. Then upgrade PHP to 8.1:sudo yum install php php-common php-cli php-fpm php-mbstring php-xml php-mysqlnd php-opcache php-gd php-curl
3. Reinstall Redis for PHP 8.1:Install the compatible php-pecl-redis version from the Remi PHP 8.1 repo: sudo yum install php-pecl-redis
It will pull the correct version (e.g., php-pecl-redis-5.x or 6.x) compiled for PHP 8.1. 📌 Notesphp(api) and php(zend-abi) are version-specific. They must match exactly for extensions to work.- Use
yum list installed | grep php to see what 7.4 packages are still lingering. |