Easy Steps To Upgrade PHP 5.3 To PHP 5.6 On CentOS 6.x And RHEL 6.x.

steps-to-upgrade-php
mm
Written By:- Santosh Prasad

In my previous article  “PHP 5.4 installation steps on CentOS 6.x and Redhat 6.x system” I explained how we can install PHP 5.4 on CentOS 6.x and RHEL 6.x. As you know PHP is the scripting language which is used to generate dynamic web page. PHP contain HTML,Text and script blocks. When user request for a PHP page through web browser than PHP script execute on web server and display the requested result in browser.

In this tutorial I am going to explain how we can upgrade PHP 5.3 to PHP 5.6 on CentOS 6.x and RHEL 6.x. I assume you have already installed LAMP stack on your system and you have PHP 5.3 version installed on your system.

STEP 1#: VERIFY RUNNING PHP CURRENT VERSION ON SYSTEM

You will need to type below command to verify current PHP version on you system. You can also verify running PHP version using phpinfo page if you have no Linux console access to run command.

Using command line:

#php -v

You will get some output like below.

PHP 5.3.3 (cli) (built: Jul 9 2015 17:39:00)
Copyright (c) 1997‐2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998‐2010 Zend Technologies

Using PHP info page:

Create phpinfo.php page on your web document root with below text.

#vim /var/www/html/phpinfo.php

<?php

phpinfo();

?>

Save and exit.

Type below URL in your browser.

http://ip_domain_name/phpinfo.php

You will get below result in your browser.

looklinux-phpinfo-5-3

STEP 2#: REPOSITORIES INSTALLATION

To Upgrade PHP 5.6 you will need to install and enable third party repositories like REMI and EPEL. Follow the below command to install and enable repository.

EPEL Repository installation:

# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm

--2016-12-21 00:07:22-- https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Resolving dl.fedoraproject.org... 209.132.181.27, 209.132.181.26, 209.132.181.23, ...
Connecting to dl.fedoraproject.org|209.132.181.27|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14540 (14K) [application/x-rpm]
Saving to: `epel-release-latest-6.noarch.rpm.2'

100%[==============================================================================================================>] 14,540 --.-K/s in 0.04s

2016-12-21 00:07:28 (363 KB/s) - `epel-release-latest-6.noarch.rpm.2' saved [14540/14540]

Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]

REMI Repository installation:

# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm

--2016-12-21 00:09:38-- http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Resolving rpms.famillecollet.com... 195.154.241.117, 2001:bc8:33a1:100::1
Connecting to rpms.famillecollet.com|195.154.241.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8159 (8.0K) [application/x-rpm]
Saving to: `remi-release-6.rpm'

100%[================================================================================================================>] 8,159 --.-K/s in 0.001s

2016-12-21 00:09:44 (12.4 MB/s) - `remi-release-6.rpm' saved [8159/8159]

warning: remi-release-6.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing... ########################################### [100%]
1:remi-release ########################################### [100%]

After installaling REMI repository you will need to enable it globally.

Enabling REMI Repository:

To enable remi repostiry for PHP 5.6 you will need to make following changes.

#vim /etc/yum.repos.d/remi.repo

[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Also you will need to make below changes in “[remi-php56]” section to install PHP 5.6.

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php56/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Save and exit.

STEP 3#: REMOVING PHP 5.3 VERSION

Now you will need to run below command to remove your PHP 5.3 version.

# yum remove php-common

You will get some output like below.

Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package php-common.i686 0:5.3.3-48.el6_8 will be erased
--> Processing Dependency: php(api) = 20090626 for package: php-mcrypt-5.3.3-5.el6.i686
--> Processing Dependency: php(language) >= 5.3 for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php(language) >= 5.2.17 for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php(zend-abi) = 20090626 for package: php-mcrypt-5.3.3-5.el6.i686
--> Processing Dependency: php-bz2 for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-ctype for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-curl for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-curl for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-date for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-date for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-filter for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-hash for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-hash for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-iconv for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-json for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-json for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-libxml for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-openssl for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-pcre for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-pcre for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-session for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-simplexml for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-spl for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-zip for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-zlib for package: php-tcpdf-6.2.11-1.el6.noarch
--> Processing Dependency: php-zlib for package: phpMyAdmin-4.0.10.17-2.el6.noarch
--> Processing Dependency: php-common for package: php-php-gettext-1.0.11-12.el6.noarch
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-pdo-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-gd-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-mysql-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-tidy-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-xml-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-fpm-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-cli-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-process-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-mbstring-5.3.3-48.el6_8.i686
--> Processing Dependency: php-common(x86-32) = 5.3.3-48.el6_8 for package: php-bcmath-5.3.3-48.el6_8.i686
--> Running transaction check
---> Package php.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-bcmath.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-cli.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-fpm.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-gd.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-mbstring.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-mcrypt.i686 0:5.3.3-5.el6 will be erased
---> Package php-mysql.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-pdo.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-php-gettext.noarch 0:1.0.11-12.el6 will be erased
---> Package php-process.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-tcpdf.noarch 0:6.2.11-1.el6 will be erased
--> Processing Dependency: php-tcpdf = 6.2.11-1.el6 for package: php-tcpdf-dejavu-sans-fonts-6.2.11-1.el6.noarch
---> Package php-tidy.i686 0:5.3.3-48.el6_8 will be erased
---> Package php-xml.i686 0:5.3.3-48.el6_8 will be erased
---> Package phpMyAdmin.noarch 0:4.0.10.17-2.el6 will be erased
--> Running transaction check
---> Package php-tcpdf-dejavu-sans-fonts.noarch 0:6.2.11-1.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================
Removing:
php-common i686 5.3.3-48.el6_8 @updates 2.9 M
Removing for dependencies:
php i686 5.3.3-48.el6_8 @updates 3.3 M
php-bcmath i686 5.3.3-48.el6_8 @updates 27 k
php-cli i686 5.3.3-48.el6_8 @updates 6.3 M
php-fpm i686 5.3.3-48.el6_8 @updates 3.3 M
php-gd i686 5.3.3-48.el6_8 @updates 312 k
php-mbstring i686 5.3.3-48.el6_8 @updates 1.9 M
php-mcrypt i686 5.3.3-5.el6 @epel 38 k
php-mysql i686 5.3.3-48.el6_8 @updates 189 k
php-pdo i686 5.3.3-48.el6_8 @updates 150 k
php-php-gettext noarch 1.0.11-12.el6 @epel 57 k
php-process i686 5.3.3-48.el6_8 @updates 53 k
php-tcpdf noarch 6.2.11-1.el6 @epel 11 M
php-tcpdf-dejavu-sans-fonts noarch 6.2.11-1.el6 @epel 1.5 M
php-tidy i686 5.3.3-48.el6_8 @updates 44 k
php-xml i686 5.3.3-48.el6_8 @updates 275 k
phpMyAdmin noarch 4.0.10.17-2.el6 @epel 20 M

Transaction Summary
======================================================================================================================================
Remove 17 Package(s)

STEP 4#: INSTALLING PHP 5.6 VERSION

After removing PHP 5.3. You will need to run below command to install PHP 5.6 version.

# yum install php php-gd php-mysql php-mcrypt -y

You will get some output like below.

Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* epel: epel.excellmedia.net
* extras: mirror.nbrc.ac.in
* remi: mirror.oxilion.nl
* remi-php56: mirror.oxilion.nl
* remi-safe: mirror.oxilion.nl
* updates: mirror.fibergrid.in
Package php-mysql is obsoleted by php-mysqlnd, trying to install php-mysqlnd-5.6.29-1.el6.remi.i686 instead
Resolving Dependencies
--> Running transaction check
---> Package php.i686 0:5.6.29-1.el6.remi will be installed
--> Processing Dependency: php-common(x86-32) = 5.6.29-1.el6.remi for package: php-5.6.29-1.el6.remi.i686
--> Processing Dependency: php-cli(x86-32) = 5.6.29-1.el6.remi for package: php-5.6.29-1.el6.remi.i686
---> Package php-gd.i686 0:5.6.29-1.el6.remi will be installed
---> Package php-mcrypt.i686 0:5.6.29-1.el6.remi will be installed
---> Package php-mysqlnd.i686 0:5.6.29-1.el6.remi will be installed
--> Processing Dependency: php-pdo(x86-32) = 5.6.29-1.el6.remi for package: php-mysqlnd-5.6.29-1.el6.remi.i686
--> Running transaction check
---> Package php-cli.i686 0:5.6.29-1.el6.remi will be installed
---> Package php-common.i686 0:5.6.29-1.el6.remi will be installed
--> Processing Dependency: php-pecl-zip(x86-32) for package: php-common-5.6.29-1.el6.remi.i686
--> Processing Dependency: php-pecl-jsonc(x86-32) for package: php-common-5.6.29-1.el6.remi.i686
---> Package php-pdo.i686 0:5.6.29-1.el6.remi will be installed
--> Running transaction check
---> Package php-pecl-jsonc.i686 0:1.3.10-1.el6.remi.5.6 will be installed
---> Package php-pecl-zip.i686 0:1.13.5-1.el6.remi.5.6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================
Installing:
php i686 5.6.29-1.el6.remi remi-php56 2.7 M
php-gd i686 5.6.29-1.el6.remi remi-php56 75 k
php-mcrypt i686 5.6.29-1.el6.remi remi-php56 48 k
php-mysqlnd i686 5.6.29-1.el6.remi remi-php56 270 k
Installing for dependencies:
php-cli i686 5.6.29-1.el6.remi remi-php56 4.1 M
php-common i686 5.6.29-1.el6.remi remi-php56 1.1 M
php-pdo i686 5.6.29-1.el6.remi remi-php56 114 k
php-pecl-jsonc i686 1.3.10-1.el6.remi.5.6 remi-php56 51 k
php-pecl-zip i686 1.13.5-1.el6.remi.5.6 remi-php56 51 k

Transaction Summary
======================================================================================================================================
Install 9 Package(s)

Total download size: 8.4 M
Installed size: 29 M
Downloading Packages:
(1/9): php-5.6.29-1.el6.remi.i686.rpm | 2.7 MB 00:03
(2/9): php-cli-5.6.29-1.el6.remi.i686.rpm | 4.1 MB 00:10
(3/9): php-common-5.6.29-1.el6.remi.i686.rpm | 1.1 MB 00:02
(4/9): php-gd-5.6.29-1.el6.remi.i686.rpm | 75 kB 00:00
(5/9): php-mcrypt-5.6.29-1.el6.remi.i686.rpm | 48 kB 00:00
(6/9): php-mysqlnd-5.6.29-1.el6.remi.i686.rpm | 270 kB 00:00
(7/9): php-pdo-5.6.29-1.el6.remi.i686.rpm | 114 kB 00:00
(8/9): php-pecl-jsonc-1.3.10-1.el6.remi.5.6.i686.rpm | 51 kB 00:00
(9/9): php-pecl-zip-1.13.5-1.el6.remi.5.6.i686.rpm | 51 kB 00:00
--------------------------------------------------------------------------------------------------------------------------------------
Total 427 kB/s | 8.4 MB 00:20
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-pecl-jsonc-1.3.10-1.el6.remi.5.6.i686 1/9

WARNING : These php-* RPMs are not official Fedora / Red Hat build and
overrides the official ones. Don't file bugs on Fedora Project nor Red Hat.

Use dedicated forum at http://forum.remirepo.net/

Installing : php-common-5.6.29-1.el6.remi.i686 2/9
Installing : php-pecl-zip-1.13.5-1.el6.remi.5.6.i686 3/9
Installing : php-cli-5.6.29-1.el6.remi.i686 4/9
Installing : php-pdo-5.6.29-1.el6.remi.i686 5/9
Installing : php-mysqlnd-5.6.29-1.el6.remi.i686 6/9
Installing : php-5.6.29-1.el6.remi.i686 7/9
Installing : php-mcrypt-5.6.29-1.el6.remi.i686 8/9
Installing : php-gd-5.6.29-1.el6.remi.i686 9/9
Verifying : php-pecl-zip-1.13.5-1.el6.remi.5.6.i686 1/9
Verifying : php-cli-5.6.29-1.el6.remi.i686 2/9
Verifying : php-5.6.29-1.el6.remi.i686 3/9
Verifying : php-mcrypt-5.6.29-1.el6.remi.i686 4/9
Verifying : php-pecl-jsonc-1.3.10-1.el6.remi.5.6.i686 5/9
Verifying : php-gd-5.6.29-1.el6.remi.i686 6/9
Verifying : php-mysqlnd-5.6.29-1.el6.remi.i686 7/9
Verifying : php-pdo-5.6.29-1.el6.remi.i686 8/9
Verifying : php-common-5.6.29-1.el6.remi.i686 9/9

Installed:
php.i686 0:5.6.29-1.el6.remi php-gd.i686 0:5.6.29-1.el6.remi php-mcrypt.i686 0:5.6.29-1.el6.remi
php-mysqlnd.i686 0:5.6.29-1.el6.remi

Dependency Installed:
php-cli.i686 0:5.6.29-1.el6.remi php-common.i686 0:5.6.29-1.el6.remi php-pdo.i686 0:5.6.29-1.el6.remi
php-pecl-jsonc.i686 0:1.3.10-1.el6.remi.5.6 php-pecl-zip.i686 0:1.13.5-1.el6.remi.5.6

Complete!

After installing PHP 5.6 you will need to restart your Apache service to take effect.

#service httpd restart

Stopping httpd: [ OK ]
Starting httpd: [ OK ]

Step 5#: VERIFY RUNNING PHP CURRENT VERSION ON SYSTEM

Run below command to verify PHP current version.

Using command line:

# php -v

PHP 5.6.29 (cli) (built: Dec 8 2016 08:43:18)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

You will get some output like above.

Using PHP info page:

Create phpinfo.php page on your web document with below text.

#vim /var/www/html/phpinfo.php

<?php

phpinfo();

?>

Save and exit.

Type below url in your browser

http://ip_domain_name/phpinfo.php

You will get below result in your browser.

looklinux-phpinfo-5-6

Now you can see PHP 5.3 has been upgraded to PHP 5.6.

I hope this article will be helpful to understand how we can upgrade PHP 5.3 to PHP 5.6 on CentOS 6.x and RHEL 6.x system. If you have any queries and problem please comment in comment section or you can also ask your question.

Thanks:)

About Author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Other Post by Santosh Prasad

Visit All Post

Related Article

You may also Like

Leave a Comment

Shares