Score:1

Apache remains on PHP 7 while server versions is php 8

ug flag

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.

ug flag
@MichaelHampton I've updated the question with the package installed. Not sure if I restarted PHP, which command would that be?
ug flag
I did install PHP8
Michael Hampton avatar
cz flag
I reviewed your edit but it doesn't show anything about you installing PHP 8. How did it get onto your system?
ug flag
I've installed php 8 through the commands generated via https://rpms.remirepo.net/wizard/. I added each command I ran in the question.
Michael Hampton avatar
cz flag
Undo the installation of php80 and start over. You selected "Multiple versions simultaneously" and you should have selected "Default / Single version (simplest way)".
Score:2
in flag

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.

ug flag
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?!?
t3ln3t avatar
in flag
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.
Remi Collet avatar
jp flag
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 avatar
jp flag
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
ug flag
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.
ug flag
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
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.