如何安装php 5.3.14 ubuntu 12.10

I have to install this specific version on my ubuntu 12.10 to keep compatible with provider. I could install php 5.3.10 easily with synaptic, but could not upgrade to 5.3.14. How can i do that ? Apt-get doesnt work... I saw several tutos on the web, but nothing specific to this one.

This should override apt-get to fetch the latest version of PHP (but I think only stable, so all alpha/beta versions probably won't be installed)

sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install php5
php5 -v

Furthermore you can update you apt preferences to never install a higher update of a package. You can do this by opening up /etc/apt/preferences and add the following:

Package: php
Pin: release v=5.3.14*,a=stable,c=main,o=Debian,l=Debian
Pin-Priority: 1001

This is an Debian example, but Ubuntu is based on Debian and as I can't test it on a live Ubuntu distro at the moment, I think this will likely suffice.

To make this "version-blockade" work you probably first need to uninstall php through apt-get and then reinstall it so it will stick to 5.3.14.

Remove and purge packages:

apt-get remove php-apc php5 php5-mysql php5-gd php5-curl libapache2-mod-php5

apt-get autoremove

Make sure you understand what this command does before running it:

dpkg -l | grep '^rc' | awk '{print $2}' | xargs dpkg --purge

You can usually add sources from old versions without worrying too much:

/etc/apt/sources.list.d/precise.list

deb http://mirror.rackspace.com/ubuntu/ precise main restricted
deb-src http://mirror.rackspace.com/ubuntu/ precise main restricted
deb http://mirror.rackspace.com/ubuntu/ precise-updates main restricted
deb-src http://mirror.rackspace.com/ubuntu/ precise-updates main restricted
deb http://mirror.rackspace.com/ubuntu/ precise universe
deb-src http://mirror.rackspace.com/ubuntu/ precise universe
deb http://mirror.rackspace.com/ubuntu/ precise-updates universe
deb-src http://mirror.rackspace.com/ubuntu/ precise-updates universe

Here is a possibly too broad, but hopefully instructive apt preferences file:

/etc/apt/preferences.d/php_precise

Package: php5
Pin: release a=precise
Pin-Priority: 1001

Package: php*
Pin: release a=precise
Pin-Priority: 1001

Package: php-*
Pin: release a=precise
Pin-Priority: 1001

Package: libapache2-mod-php5
Pin: release a=precise
Pin-Priority: 1001

Package: php5
Pin: release a=precise-updates
Pin-Priority: 1001

Package: php*
Pin: release a=precise-updates
Pin-Priority: 1001

Package: php-*
Pin: release a=precise-updates
Pin-Priority: 1001

Package: libapache2-mod-php5
Pin: release a=precise-updates
Pin-Priority: 1001

Update and check your changes

apt-get update

apt-cache policy <package> to check which version will be installed (eg php5)

Do some test runs, you may have dependencies that you need to add to the preferences file

apt-get install <everything you removed before>