1

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.

Robert Bouten
  • 113
  • 1
  • 5

1 Answers1

2

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.

t3ln3t
  • 434
  • 2
  • 8
  • Thnx, that command isn't working for me, but the apache config located at /etc/httpd/conf/httpd.conf indeed points to conf.modules.d/*.conf in which 15-php72-php.conf is present. So guessing that I need a change there to point to php80 instead of php72?!? – Robert Bouten Jun 13 '21 at 19:14
  • make sure you save a copy of that config file unmodified before you go making modifications. At least you can put it back on working php7 should your modifications not work for some reason. Otherwise I would say yes. – t3ln3t Jun 13 '21 at 19:49
  • You probably need to remove mod_php (php72-php package) and install proper version (php80-php), btw as said by Michael Hampton, simpler to follow the Wizard instructions for "single version", unless your really want multiple version. – Remi Collet Jun 14 '21 at 09:25
  • And if you need multiple version, I recommend you switch to FPM and read https://developers.redhat.com/blog/2017/10/25/php-configuration-tips – Remi Collet Jun 14 '21 at 09:26
  • Thnx @RemiCollet I started out by installing the single version, but the result was the same. It seems that previously in the apache config some particular config was done with deep symlinking to the php version. Trying to untangle & resolve that now. – Robert Bouten Jun 15 '21 at 07:12
  • Eventually I ended up removing php and reinstalling through: yum remove php* yum install php php-{cli, fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json} service http configtest systemctl start httpd – Robert Bouten Jun 17 '21 at 12:31