Apache remains on PHP 7 while server versions is php 8

I've just installed php 8 (following https://rpms.remirepo.net/wizard/) on my VPS running CentOS 7. While in the CLI it shows that PHP 8 is available, when I serve a webpage with phpinfo() it still shows php 7.

PHP 8.0.7 (cli) (built: Jun  1 2021 18:43:05) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.7, Copyright (c) Zend Technologies

Also when I check with composer it shows php 8

Running 2.1.3 (2021-06-09 16:31:20) with PHP 8.0.7 on Linux / 3.10.0-1127.18.2.el7.x86_64

But via a webpage displaying phpinfo() it shows

PHP Version 7.2.34

The commands I ran (from the remi wizard) to install PHP are:

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum install yum-utils

yum  install php80

Next I tried restarting apache with 'sudo systemctl restart httpd.service' but this didn't resolve. I suspect that somehow I need to still switch between both PHP versions but I don't know if that's the cause or how to do so.

Some more info

$ which php
/usr/bin/php

$ whereis php
php: /usr/bin/php /usr/lib64/php /etc/php.ini /etc/php.d /usr/include/php /usr/share/php /usr/share/man/man1/php.1.gz

whereis php80
php80: /usr/bin/php80

$ httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 16 2020 16:18:20

My search further (thnx t3ln3t) brought me to the apache config files, which references a php7 config file which then points to 'libphp72.so'. So I am guessing that eventually that needs to point to php8. But although php8 is installed, I don't see a libphp80.so file.

Thank you for any guidance on what I should do next to make the apache config point to the newly installed php8 version.


Solution 1:

This is likely a case of two versions installed on your system. If you look at the rpms you have installed, you will likely find php7 has been installed and lives someplace else on the system. Very likely in the search path apache uses to find things. Also, review your apache configuration file. mod_php is very likely named and a full path to that module is present.

#rpm -qa | grep php

This command should show you all installed versions of php that were installed using rpms. If php7 was installed from a source distribution or tarball someone made or found, this is going to SUCK!!! If you find php7 rpms, schedule some maintenance (down time) for your website, remove the old php rpms and then restart apache. Again, take care to look at your apache config files as mod_php is likely named and a full path is present. You will want to modify that to let apache know to look at the newer version of php.