Date Posted on:04-01-2017

Ubuntu 16.04 doesn’t have php 5.6 by default. Normally, if we install php on ubuntu 16.04, it will install php 7. Many application (at the time of this post 04-01-2017) runs only with php 5.6 and may face issue with Php7. In this post, we are gonna explain on how to install php 5.6.

Assumption:
  1. Ubuntu 16.04
  2. Server Root access
Installation:

Add a PPA repo(Personal Package Archive) to the server.

add-apt-repository ppa:ondrej/php

Since this post deals with php 5.6, we haven’t included any steps to install previous version of php such as php 5.5 or php 5.4. Moreover, php 5.5 and php 5.4 are no longer supported with security updates.

Now, Install php 5.6 application using apt-get.

apt-get install php5.6 php5.6-dev php5.6-curl php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-zip

You will prompted to Press Enter to continue. To continue, press Enter continue

The above command will  most of the dependencies including apache2 and all other dependency packages.

Start apache2 service and enable the service on systemctl.

systemctl start apache2

systemctl enable apache2

Let’s check the php version.

php -v
PHP 5.6.29-1+deb.sury.org~xenial+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

 

Create a phpinfo page on the domain documentroot or server documentroot. By default, the location will be /var/www/html

vi /var/www/html/info.php

<?php

phpinfo();

?>

Access the page on the browser http://IPADDRESS/info.php. You will see php info page with php 5.6 version.

 

 

Leave a Reply