How to upgrade PHP 5.4 to PHP 5.6 on Debian GNU/Linux 7 (wheezy)

Solution 1:

(Update) Try this (Ubuntu):

sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php5.6-fpm -y

(Update) For Debian Wheezy (with sudo)

echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list
echo "deb-src http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list
wget http://www.dotdeb.org/dotdeb.gpg -O- | apt-key add - 
apt-get update
apt-get install php5-cli php5-fpm ….. (or whatever package you might need)

(Update 21/06/2017) For Debian 8 (jessie)

sudo nano /etc/apt/sources.list

Add the following repositories:

...
deb http://mirrors.digitalocean.com/debian jessie main contrib non-free
deb-src http://mirrors.digitalocean.com/debian jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

# jessie-updates, previously known as 'volatile'
deb http://mirrors.digitalocean.com/debian jessie-updates main contrib non-free
deb-src http://mirrors.digitalocean.com/debian jessie-updates main contrib non-free

Then update your sources:

sudo apt-get update

Then install the php5-fpm

sudo apt-get install php5-fpm

Solution 2:

sudo nano /etc/apt/sources.list

add

deb http://packages.dotdeb.org wheezy all
deb-src http://packages.dotdeb.org wheezy all
deb http://packages.dotdeb.org wheezy-php56-zts all
deb-src http://packages.dotdeb.org wheezy-php56-zts all

save and run

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5 

more info here https://www.dotdeb.org/instructions/