Wednesday, October 19, 2016

Updating Default PHP 5.5.9 to PHP 5.6 on Ubuntu 14.04

Presuming that we have the default PHP 5.5.9 which comes with Ubuntu 14.04.5 (Trusty):

root@indra:/# php -v
PHP 5.5.9-1ubuntu4.20 (cli) (built: Oct  3 2016 13:00:37)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

 and we want to upgrade to PHP 5.6, here are the steps:

1. Patch the system first.

apt-get update
apt-get upgrade -y

2. Restart the server.


3. Add the repository and install PHP 5.6:

apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl

4. Re-configure Apache to use PHP 5.6:

a2dismod php5
a2enmod php5.6
service apache2 restart

5. Verify that PHP 5.6 is running. On CLI:

php -v

root@indra:/etc/apache2# php -v
PHP (cli)
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

On CGI, access phpinfo() PHP script using a browser and verify PHP 5.6 is being shown.

No comments: