Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have just installed a 10.04 LTS on my development server but the system that I need to run on it (Magento ecommerce) is not compatible with PHP 5.3 which ships with the newest version of Ubuntu. Is there a safe and upgrade-proof way of getting PHP 5.2 installed or will it be easier to use an older version of Ubuntu?

share|improve this question

4 Answers 4

up vote 7 down vote accepted

You can use my ppa, that I have created for this purpose. Please take notice of the pinning that is necessary. Also, aptitude will not recognize the pinning. You must use the aptitude specific method if you want to use it.

share|improve this answer
1  
Where is your PPA? –  Nathan Osman Jul 28 '10 at 20:08
    
Sorry.. I am not so fast :D launchpad.net/~txwikinger/+archive/php5.2 –  txwikinger Jul 28 '10 at 20:10
    
Could you also explain what I should do with this ppa? –  silvo Jul 30 '10 at 18:23
    
@silvo: you need to add the ppa to your sources lists, either by using your package manager or using add-apt-repository on the commandline. The details for the ppa are on the website of the ppa. –  txwikinger Jul 30 '10 at 20:09
    
This is pretty much the perfect answer, thanks. For those unsure, to add the ppa to your sources do sudo add-apt-repository ppa:txwikinger/php5.2 from the command line. Be sure to follow the ppa link in the post and apply txwikinger's pinning solution. Make sure you run sudo apt-get update before you try and install the packages! –  adamnfish Feb 8 '11 at 16:31

It is possible to use karmic packages and pin them with aptitude. This can be done by using this commands:

# remove all php packge
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
# use karmiс for php pakage
# pin-params:  a (archive), c (components), v (version), o (origin) and l (label).
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n"  | sudo tee   /etc/apt/preferences.d/php > /dev/null
apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release   a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null
apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null
echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n"  | sudo tee -a     /etc/apt/preferences.d/php > /dev/null
# add karmic to source list
grep 'main restricted' /etc/apt/sources.list|grep -v "#"| sed s/lucid/karmic/g | sudo tee             /etc/apt/sources.list.d/karmic.list > /dev/null
# update package database (use apt-get if aptitude crash)
sudo apt-get update
# install php
sudo aptitude install -t karmic php5-cli php5-cgi
# or (and) sudo apt-get install -t karmic  libapache2-mod-php5
sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`
#done

Got this from link text

share|improve this answer

I've recently tried to solve the same problem myself. Instead of making changes to the package management I compiled PHP 5.2.17 from the source code myself and then used the program Checkinstall to install the new .deb package on my system.

I wrote up the steps in a blog post, Compiling PHP 5.2 for Ubuntu 10.10, but the steps basically involved the following:

  1. Download PHP source (http://php.net/downloads.php) to /usr/local/src
  2. Configure source, reading INSTALL doc and output from ./configure --help

my configure command looked like this:

./configure --prefix=/opt --with-apxs2=/usr/bin/apxs2 --with-curl=/usr/lib --with-pgsql --with-pear --with-mysql --with-gd
  1. Compile the source using 'make'
  2. Install the compiled package using 'checkinstall'

And that was it. I had already installed Apache2 using Synaptic (you need to use the apache2-mpm-prefork package for use with PHP). Also if you had any PHP5 pacakges already installed you would need to uninstall them before trying to install your own compiled package.

Compiling the package yourself really doesn't take long at all and is a good experience if you haven't done it already on your Ubuntu machine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.