Upgrade PHP 5.4.x to 5.6.x (CentOS 7)

Send Us a Sign! (Contact Us!)

On older system that use still PHP 5.4 it could be necessary, especially if the web solution needs it, to upgrade it to PHP 5.6. Main features include in PHP 5.6.0:

  • Constant scalar expressions.
  • Exponentiation utilizing the ** operator.
  • Function and constant importing with the utilization decisive word.
  • phpdbg as an intuitive coordinated debugger SAPI.
  • GMP questions now bolster operator over-burdening.
  • Document transfers bigger than 2 gigabytes in size are presently acknowledged.

First we need to check the current version of PHP. To check the versio of PHP run following command:

php -v
PHP 5.4.35 (cli) (built: Nov 14 2014 07:04:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies

To upgrade php, first you must include the Webtatic EL yum repository data relating to your CentOS/RHEL variant to yum:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

Check PHP list Packages:

yum list installed php

Remove all PHP Packages:

$ sudo yum remove php php-cli php-common php-gd php-ldap php-mysql php-odbc php-pdo php-pear php-pecl-apc php-pecl-memcache php-pgsql php-soap php-xml php-xmlrpc -y

Restart Apache web server daemon:

$ sudo service httpd restart

Install PHP 5.6.x:

sudo yum install php56w php56w-opcache -y

Install PHP 5.6.x Packages:

sudo yum install php56w-mcrypt php56w-intl php56w-odbc php56w-pdo php56w-pgsql php56w-soap php56w-xml php56w-gd php56w-mbstring -y

Install MySQL Modules:

sudo yum install php56w-mysqlnd

Check PHP Version again:

$ php --version
PHP 5.6.21 (cli) (built: May 1 2016 11:06:02)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

For the full list of PHP 5.6.x packages, you can refer to the following table:

PackageProvides
php56wmod_php, php56w-zts
php56w-bcmath
php56w-cliphp-cgi, php-pcntl, php-readline
php56w-commonphp-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-ereg, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
php56w-dba
php56w-devel
php56w-embeddedphp-embedded-devel
php56w-enchant
php56w-fpm
php56w-gd
php56w-imap
php56w-interbasephp_database, php-firebird
php56w-intl
php56w-ldap
php56w-mbstring
php56w-mcrypt
php56w-mssql
php56w-mysqlphp-mysqli, php_database
php56w-mysqlndphp-mysqli, php_database
php56w-odbcphp-pdo_odbc, php_database
php56w-opcachephp56w-pecl-zendopcache
php56w-pdophp56w-pdo_sqlite, php56w-sqlite3
php56w-pear
php56w-pecl-apcu
php56w-pecl-gearman
php56w-pecl-geoip
php56w-pecl-imagick
php56w-pecl-memcache
php56w-pecl-memcached
php56w-pecl-mongodb
php56w-pecl-xdebug
php56w-pgsqlphp-pdo_pgsql, php_database
php56w-phpdbg
php56w-processphp-posix, php-sysvmsg, php-sysvsem, php-sysvshm
php56w-pspell
php56w-recode
php56w-snmp
php56w-soap
php56w-tidy
php56w-xmlphp-dom, php-domxml, php-wddx, php-xsl
php56w-xmlrpc