1

I have a development VM server (Centos7+php5.4+apache2.4) and each user as it sub domain, developing its webservice.

Most of the developers are obligated to code on the 5.4 php version, with mod_php as default and I have instructions to migrate to PHP 7 (preferably 7.2), as soon as possible. I researched and read that the only option to have two different versions of PHP,is that I have to install one of them with Fast-CGi (I dont mind doing that on php7). I'm concerned that when its possible to choose the necessary php version will affect the development, because of the different environments (mod_php vs Fast-CGi)

So far I only could install both of the php versions+necessary modules, without any issue. It's possible to the system recognizes the newer php version and force a chosen user to use that version?

I've tried using the procedure with virtualmin and create PHP install packages without success. The virtualmin installs a lot of extra stuff that cause instability on the system.

So far I've tried all of this procedures:

https://www.webfoobar.com/node/45

https://www.centos.org/forums/viewtopic.php?f=47&t=62204

https://rpms.remirepo.net/wizard/ (success installing the two versions on the same system)

My objective is to choose what php version should each user (under his sub-domain) will work without any version conflicts, maintaining the system (EOL) php 5.4 temporarily. I read that its possible with the .htaccess configuration with Add-handler, but the system didn't recognize the php7

Any guidance accepted. Thanks for the reading Best regards

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
Papa Lopez
  • 11
  • 1
  • 2

3 Answers3

1

install other versions of PHP in centos 7


Setup Yum Repository First of all, you need to enable Remi and EPEL yum repositories on your system. Use the following command to install EPEL repository on your CentOS and Red Hat 7/6 systems

Use this command to install EPEL yum repository on your system

 sudo yum install epel-release

and now execute one of the following commands as per your operating system version to install the Remi repository.

sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Install PHP 7 on CentOS Your system is prepared for the PHP installation from yum repositories. Use one of the following commands to install PHP 7.4 or PHP 7.3 or PHP 7.2 on your system based on your requirements.

Install PHP 7.4

yum --enablerepo=remi-php74 install php

Install PHP 7.3

yum --enablerepo=remi-php73 install php

Install PHP 7.2

yum --enablerepo=remi-php72 install php


php -v

.

PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Install PHP Modules You may also need to install additional PHP modules based on your application requirements. The below command will install some more useful PHP modules.

For PHP 7.4

yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

For PHP 7.3

yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

For PHP 7.2

yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

.
.
.

*** note: Do not install or use versions earlier than PHP7.2.

Versions PHP 5.x through php-7.1 are obsolete and MUST NOT be used. Please note that older versions are listed for archival purposes only and are no longer supported.


Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
0

My objective is to choose what php version should each user

You have to drop mod_php usage, and use php-fpm instead, which can be set for each subdomain.

I recommend you read PHP Configuration Tips which explain how to run such configuration.

You can of course use official SCLs (rh-php72 or rh-php73) or the ones in "remi" repository (php56 to php80)

For your information, FPM is now the default configuration in CentOS 8.

Notice: the SetHandler can be set in a .htaccess file, but probably cleaner to set it in the subdomain vhost configuration.

Remi Collet
  • 6,198
  • 1
  • 20
  • 25
0

Centos 8 >> install php 7.4

To install and enable the EPEL repository on CentOS 8, execute the following dnf command.

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

To confirm the presence of the EPEL repository, run the following rpm command.

 rpm -qa | grep epel

Next, run the command below to add the Remi repository.

 dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Once again, to verify the existence of the Remi repository, run the command.

 rpm -qa | grep remi

Step 2: Install PHP 7.4 on CentOS 8 Upon successful addition of EPEL and Remi repositories, execute the command below to get a list of available PHP module streams.

 dnf module list php

List PHP Modules From the output above, remi-7.4 is the latest PHP stream, and therefore we are going to enable the module stream as shown below.

dnf module enable php:remi-7.4

Enable PHP Remi Stream Once the PHP remi-7.4 module has been enabled, you can then proceed and install PHP using the command below. This will also install a host of other packages such as Apache and Nginx modules.

 dnf install php php-cli php-common

#Install PHP on CentOS 8 To check the version of PHP installed, run the command.

 php -v

Verify PHP Installed Version From the output, we can clearly see that we have installed PHP version 7.4