Installing php 5.6 on CentOS 7

enable EPEL and Remi repository to your CentOS 7 system using the commands below.

# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

install yum utils

# yum install yum-utils

The most important program provided by yum-utils is yum-config-manager, which you can use to active Remi repository as the default repository for installing various PHP versions.

For example, if you want to install PHP 5.5PHP 5.6 or PHP 7.2 on CentOS 7, just enable it and install as shown.

# yum-config-manager --enable remi-php55   [Install PHP 5.5]
# yum-config-manager --enable remi-php56   [Install PHP 5.6]
# yum-config-manager --enable remi-php72   [Install PHP 7.2]

4. Now that you’ve enabled selected versions of PHP, you can install PHP (here, we have chosen to install PHP 5.6) with all needed modules as follows

# yum-config-manager --enable remi-php56   [Install PHP 5.6]
# yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

 

  1. In case you want to downgrade the PHP version for one reason or the other, you will need to remove existing PHP version(s) and then reinstall the new PHP with modules you need.
  2. You can as well install multiple versions of PHP on Linux and manually choose which version to use by default.

Afterwards, double check the installed version of PHP on your system.

# php -v

Leave a Comment