Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centos httpd php version is different from the php version command line

Tags:

php

centos

redhat

I'm on Centos7 i have enable multiple php versions with remi repo like :

yum-config-manager --enable remi-php56
yum-config-manager --enable remi-php71
yum-config-manager --enable remi-php72
yum-config-manager --enable remi-php73

Then installed the packages :

yum install php{version}
yum install php{version}-php-{extension}

I have setup PHP5.6 like :

sudo update-alternatives --set php /usr/bin/php56

When i make php-v :

PHP 5.6.40 (cli) (built: Sep 29 2020 11:38:05)

But when i'm going to my phpinfo() file i get PHP Version 7.3.23

In centos/RH we can't make :

sudo a2enmod php56 

so i'm confusing and i don't know why httpd interpret version 7.3.23

How could i setup a PHP specific version to httpd?

enter image description here

like image 497
Mathieu Mourareau Avatar asked Sep 05 '25 03:09

Mathieu Mourareau


1 Answers

You are confused by 2 set of packages:

  • base packages (php-*), 1 repository per version (remi-php##) and where you can install a single (and default) version
  • SCL packages (php##-php-*) design for parallel installation of multiple versions

See the repository FAQ.

If you want to install and run multiple versions, you have to use the SCLs and switch to FPM (instead of mod_php, this is the default way on CentOS 8).

In short, configure each FPM instance to run on a specific socket (network port or UDS), and configure Apache to use the proper version per virtual host, project, directory... using the SetHandler directive.

I recommend you read PHP Configuration Tips

You can also read My PHP Workstation

like image 82
Remi Collet Avatar answered Sep 07 '25 22:09

Remi Collet