How to install PHP 5.6 on Ubuntu 17.04

To install PHP 5.6 on Ubuntu 17.04

PHP is a popular general-purpose scripting language mostly used for the web development. Since it is fast, flexible and pragmatic, PHP is capable of powering everything from your blog to the most popular websites in the world. This tutorial covers the installation procedure of PHP 5.6 on Ubuntu 17.04.

Installation procedure

To proceed with the installation procedure, add the repository by executing the following command.

root@linuxhelp:~# add-apt-repository ppa:ondrej/php
 Co-installable PHP versions: PHP 5.6, PHP 7.0, PHP 7.1 and most requested extensions are included.
.com
PLEASE DON' T USE PHP 5.4 OR PHP 5.5. The PHP 5.5 and later are no longer supported with security updates, therefore they are not included in this repository.
You can get more information about the packages at https://deb.sury.org

BUGS& FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reportin
PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:
# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keybox ' /tmp/tmpouimahbf/pubring.gpg'  created
gpg: /tmp/tmpouimahbf/trustdb.gpg: trustdb created
gpg: key 4F4EA0AAE5267A6C: public key " Launchpad PPA for Ond?ej Surý "  imported
gpg: Total number processed: 1
gpg:               imported: 1
OK

The repositories are added successfully. Update your system by running the apt-get update command.

root@linuxhelp:~# apt-get update
Hit:1 http://in.archive.ubuntu.com/ubuntu zesty InRelease                      
Hit:2 http://security.ubuntu.com/ubuntu zesty-security InRelease               
Hit:3 http://in.archive.ubuntu.com/ubuntu zesty-updates InRelease              
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu zesty InRelease [20.8 kB]
Hit:5 http://in.archive.ubuntu.com/ubuntu zesty-backports InRelease            
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu zesty/main i386 Packages [38.1 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu zesty/main amd64 Packages [38.1 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu zesty/main Translation-en [20.6 kB]
Fetched 118 kB in 3s (35.6 kB/s)          
Reading package lists... Done

Now install PHP and its required extensions by executing the following command.

root@linuxhelp:~# apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-intl php5.6-intl php5.6-mbstring  php5.6-cli php5.6-gd php5.6-curl php5.6-sqlite3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php5.6-cli is already the newest version (5.6.31-4+ubuntu17.04.1+deb.sury.org+4).
php5.6-cli set to manually installed.
Suggested packages:
  libmcrypt-dev mcrypt
The following NEW packages will be installed:
.
.
.
Creating config file /etc/php/5.6/mods-available/pdo_sqlite.ini with new version
Processing triggers for libapache2-mod-php5.6 (5.6.31-4+ubuntu17.04.1+deb.sury.org+4) ...
Setting up libmcrypt4 (2.5.8-3.3) ...
Setting up php5.6-mcrypt (5.6.31-4+ubuntu17.04.1+deb.sury.org+4) ...

Creating config file /etc/php/5.6/mods-available/mcrypt.ini with new version
Processing triggers for libc-bin (2.24-9ubuntu2) ...
Processing triggers for libapache2-mod-php5.6 (5.6.31-4+ubuntu17.04.1+deb.sury.org+4) ...

The installation procedure of PHP 5.6 on Ubuntu 17.04 is done successfully.

Tag : Php Ubuntu
FAQ
Q
How does PHP work with Apache?
A
After Apache decides that is is a PHP file, it gives it to the PHP interpreter. When PHP receives the file it reads through it and executes any PHP code it can find. When Apache gets the output back from PHP, it sends that output back to a browser which renders it to the screen.
Q
What is PHP and why it is used?
A
PHP stands for Hypertext Preprocessor (no, the acronym doesn't follow the name). It is an open source, server-side, scripting language used for the development of web applications. By scripting language, we mean a program that is script-based (lines of code) written for the automation of tasks.
Q
Please tell me the installation of PHP on Ubuntu?
A
To do the following steps #add-apt-repository ppa:ondrej/php then you should mention a version of PHP as follows #apt-get install php(7.0/7.1/7.2) and required modules
Q
I wanna know the latest version of PHP?
A
7.2 is latest version of PHP.
Q
If its possible to install PHP on MAC?
A
Yes. Its possible to install PHP on MAC.