Thanks to Ondřej Surý for maintaining PPA of latest PHP5 versions on launchpad. If you want to install specific version of php, then this article can be helpful for you. This article will help you for installing PHP 5.4 or PHP 5.5 for PHP 5.6 using PPA on Ubuntu 14.10, 14.04 LTS or 12.04 LTS systems. If you have already have higher version installed on your system and you need to install lower version, then you have to remove higher version first and remove apt repository from system.
Install PHP 5.4
Use the following set of command to add PPA for PHP 5.4 in your Ubuntu system and install PHP 5.4.
$ sudo apt-get install python-software-properties $ sudo add-apt-repository ppa:ondrej/php5-oldstable $ sudo apt-get update $ sudo apt-get install -y php5
Check Installed PHP Version:
# php -v PHP 5.4.35-1+deb.sury.org~precise+1 (cli) (built: Nov 19 2014 19:34:07) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
Install PHP 5.5
Use the following set of command to add PPA for PHP 5.5 in your Ubuntu system and install PHP 5.5.
$ sudo apt-get install python-software-properties $ sudo add-apt-repository ppa:ondrej/php5 $ sudo apt-get update $ sudo apt-get install -y php5
Check Installed PHP Version:
# php -v
PHP 5.5.19-1+deb.sury.org~precise+1 (cli) (built: Nov 19 2014 19:32:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
Install PHP 5.6
Use the following set of command to add PPA for PHP 5.6 in your Ubuntu system and install PHP 5.6.
$ sudo apt-get install python-software-properties $ sudo add-apt-repository ppa:ondrej/php5-5.6 $ sudo apt-get update $ sudo apt-get install -y php5
Check Installed PHP Version:
# php -v
PHP 5.6.3-1+deb.sury.org~precise+1 (cli) (built: Nov 19 2014 19:34:53)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
Great work, I successfully installed php 5.6….
me, too
Dear Author,
Could you please recheck for PHP 5.4? Because I’m using Ubuntu 15.04 and no way to do this. Below are output when I entered these commands:
W: Failed to fetch http://ppa.launchpad.net/ondrej/php5-oldstable/ubuntu/dists/vivid/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/raring/main/binary-amd64/Packages 404 Not Found [IP: x.x.x.x 80]
So, I don’t complete like as your article. Please help, thank so much!
Very helpfull, thank you very much!
Totally doesnt work for php 5.5, thanks for wasting 30 secs of my time
ubuntu 15.04
Thanks for clear article.
I would like to upgrade my PHP to 5.5 on Ubuntu 12.04.
I have seen a 2013 post http://www.dev-metal.com/how-to-setup-latest-version-of-php-5-5-on-ubuntu-12-04-lts/
that says that the PPA you suggest would also update Apache to 2.4 and I want to stay with Apache 2.2 for now.
I have checked the PPA https://launchpad.net/~ondrej/+archive/ubuntu/php5 and it does list Apache 2.4 among its packages.
Would this ppa upgrade my Apache to 2.4?
Many thanks.
Thank you