upgrading php 5.4 to 5.6 on CentOS 7

 

  • First we need to check the current version of PHP. To check the version 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:For those running on CentOS/RHEL 7:
    # rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    # rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    

    For those running on CentOS/RHEL 6:

    # rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
    
  • After installing Webtatic yum repository, you need to remove the old version of php-common package. It will also delete it dependencies packages.
    # yum remove php-common
    
  • Now we install PHP 5.6 using following command:
    # yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
    
  • After installing PHP 5.6, we need to restart Apache service.
    # systemctl restart httpd.service
    
    # php -v
    
    PHP 5.6.33 (cli) (built: Apr 17 2015 22:49:36)
    Copyright (c) 1997-2015 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
    

 

Leave a Reply

Your e-mail address will not be published. Required fields are marked *