Official Debian packages contain PHP 5.4 at the moment. If you need higher version, you need to use 3rd-party repositories such as dotdeb. Generally it is recommended to use the official packages. However, sometimes there are reasons to use third party repositories. And this is one of them. Process of upgrade to PHP 5.6 on Debian 7 “Wheezy” is pretty simple and take just a few minutes.
We are going to use Dotdeb repository. It contain a lot up-to-date packages for debian servers such as nginx, php, mysql, redis etc. Note that Dotdeb supports Debian 8.x “Jessie”, Debian 7.x “Wheezy” and Debian 6.x “Squeeze”.
1. Add the main repository to your /etc/apt/sources.list file
deb http://packages.dotdeb.org wheezy all deb-src http://packages.dotdeb.org wheezy all
2. If you want to install :
PHP 5.6 on Debian 7 “Wheezy” (without Zend thread safety):
deb http://packages.dotdeb.org wheezy-php56 all deb-src http://packages.dotdeb.org wheezy-php56 all
PHP 5.6 on Debian 7 “Wheezy” (with Zend thread safety):
deb http://packages.dotdeb.org wheezy-php56-zts all deb-src http://packages.dotdeb.org wheezy-php56-zts all
If you not sure about which version you need, you can check it by running phpinfo();
3. Fetch and install the GnuPG key
wget https://www.dotdeb.org/dotdeb.gpg sudo apt-key add dotdeb.gpg
sudo apt-get update
sudo apt-get install php5
upgrade to PHP 5.6 on Debian DONE