Upgrade to PHP 5.6 on Debian 7

Upgrade to PHP 5.6 on Debian 7
Photo by Ben / Unsplash

Debian 7 come with php 5.4.x. and it is now not secure now plus it is very good idea to get updated. right now php 5.6 or 7 can be upgraded. But php 7 is in beta now and lots of other thing related in not clear to me right now. so i am going with php 5.6.

now how can we upgrade my server to php 5.4 to php 5.6 with out any problem. i found out that official packages is not yet added to php 5.6. so i was looking for third party solution. and i found one https://www.dotdeb.org/instructions/ it is very good as it explain how to do it.

now lets start by editing the source.list file in debian.

sudo nano /etc/apt/sources.list

and add this line to your file.

for debian jessie

deb https://packages.dotdeb.org jessie all

deb-src https://packages.dotdeb.org jessie all

for debian wheezy

deb https://packages.dotdeb.org wheezy all

deb-src https://packages.dotdeb.org wheezy all

for debian squeeze

deb https://packages.dotdeb.org squeeze all

deb-src https://packages.dotdeb.org squeeze all

now to install php 5.6 from there repo add this line on the same file too

for debian wheezy  (without Zend thread safety)

deb https://packages.dotdeb.org wheezy-php56 all

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

for debian "Wheezy" (with Zend thread safety)

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

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

now save the file and do the next command below

wget https://www.dotdeb.org/dotdeb.gpg

sudo apt-key add dotdeb.gpg

Now do this command in terminal

sudo apt-get updare

sudo apt-get install php5

after that check your php version by typing "php -v" in terminal of you can use phpinfo(); in php file.