How can I upgrade PHP to a higher version for Debian Squeeze?
Upgrade all packages:
apt-get update; apt-get upgrade;
If you want to upgrade just one package (e.g. php5):
apt-get update; apt-get install php5;
For the package versions available on Debian take a look at:
http://www.debian.org/distrib/packages
If you want to install php5 5.4.4-2, that is only available on wheezy, you should add wheezy to your /etc/apt/sources.list:
deb http://ftp.us.debian.org/debian/ wheezy main non-free contrib
and then:
apt-get update
apt-get install -t wheezy php5
To don't get any surprises, you should use apt pinning in order to prevent that your system from installing packages from wheezy, just create the file /etc/apt/preferences
Package: *
Pin: release n=squeeze
Pin-Priority: 650
Package: *
Pin: release n=wheezy
Pin-Priority: -10
So when that when you do apt-get install, if you don't specify -t wheezy it will by default install the package from squeeze.
Pinning is going to put you in dependency hell, as @Juan noticed. When I want the bleeding edge on my Debian systems I usually turn to http://www.dotdeb.org/
For proper instructions -> http://www.dotdeb.org/instructions/
Debian stable is designed to be really, really stable; thus using newer versions of packages is usually not supported, often tricky and/or a bad idea, and sometimes impossible. That said, there are ways to do it:
- Check out backports.debian.org, see if the package you want is there - this is the "supported" way.
- If not available, do a simple sid backport: http://wiki.debian.org/SimpleBackportCreation (use the dev libraries installed on your system to compile the package sources from debian testing or unstable)
- Installing .debs from a different repository (e.g. wheezy or ubuntu) is a very bad idea.
If no backport is available, and a simple sid backport is not possible, then you probably will not be able to get the package working on your system. You can consider upgrading to debian testing (which is not so bad when testing is under freeze, as Debian Wheezy is as of this writing).
This answer would not be complete without repeating the "simple sid backport" instructions given by the dpkg bot on irc.debian.org:
- Open sources.list and add a deb-src line for sid (not a deb line!)
- enable debian-backports (
- execute the following in your terminal of choice:
- aptitude update;
- aptitude install build-essential;
- aptitude build-dep packagename;
- apt-get -us -uc -b source packagename
- install the resultant debs.
See also: http://wiki.debian.org/Backports