Cannot add PPA: 'ppa:ondrej/php5-5.6'

add the right ppa first, do the following

  1. sudo add-apt-repository ppa:ondrej/php
  2. sudo apt-get update
  3. sudo apt-get -y 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 php5.6-zip

i had the same issue in installing the php5.6 then i did the above steps.


While the answer of @tanveerahmaddar provides crucial information, here is the correct way to install the PHP 5.6 on Ubuntu 12.04:

Important: If you plan to use PHP5.6 in websites (which you probably wish to), you have to upgrade to Apache 2.4, which does not ship with Ubuntu 12.04 (will cover the upgrade of Apache below)

Step 1: Check versions

# check PHP version
php -v
# check Apache version
apache2 -v

If your Apache version is 2.2, follow Step 2; if version is 2.4, skip to Step 3

Step 2: Add PHP5.6+ repository and update package list

add-apt-repository ppa:ondrej/apache2
apt-get update
apt-get upgrade

This step will upgrade Apache from 2.2 to 2.4. Re-configure your Apache if needed. Backup your existing Apache configurations, enabled sites and mods. You might need to re-install / upgrade some of the mods.

Step 3: Add PHP5.6+ Repository

add-apt-repository ppa:ondrej/php
apt-get update

Step 4: Install PHP 5.6

apt-get install -y 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 php5.6-zip libapache2-mod-php5.6

This will install PHP 5.6 and some common packages such as cURL (php5.6-curl) and GD (lib5.6-gd), as well as enable PHP 5.6 in Apache 2.4 (libapache2-mod-php5.6).

Apache will be restarted during the process.

That's all steps you have to do.


Hint: If you want to upgrade to PHP 7 instead (off-topic), just issue the following command after Step 3 (skip Step 4):

apt-get dist-upgrade

Final words: Not recommend to upgrade to PHP 5.6 in Ubuntu 12.04, as it involves upgrading Apache to 2.4. Ubuntu 14.04 comes with Apache 2.4, which is a lot easier to upgrade PHP 5.6.


This work for perfectly for me. Add the right PPA first, by doing the following

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y 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 php5.6-zip

Disable php 5.5.3 or 5.5.9 module

a2dismod php5

Enable the just installed php5.6 module

a2enmod php5.6

Finally, you restart your apache

sudo service apache restart

@tanveer ahmad dar highlighted most of it.

Tags:

Php

Ubuntu