Contents...
In my previous article “PHP 5.4 Installation” 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.
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 URLs to install and enable repository.
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: Install 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 Current PHP 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.
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.
Suggested Read:
- How To Prevent SQL Injection In PHP
- How To Enable And Disable PHP Error Logging Using .htaccess File
- How To Set PHP Maximum Execution Time In An .htaccess File
- How To Enable Displaying PHP Errors On Site
- How To Increase PHP Script Execution Time With Nginx
- Increase File Upload Size Limit In PHP-Nginx
- How To Install PHP-GD On Ubuntu And Debian System
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Thank you very much Santosh ,
This upgrade worked perfect.
Thanks again
Perfectly working, Thanks