6

I would like to know if there is any repository I can add to install php5.2.9+ on Ubuntu Server 12.04.

Aditya
  • 13,416
  • Why 5.2.x? Why not the latest? Related: http://askubuntu.com/questions/109404/how-do-i-install-php-5-4-0 – Oli Feb 28 '13 at 16:08
  • unfortunately its an external application to our organization and they require php version 5.2.9 to 5.2.x – user136441 Feb 28 '13 at 16:18
  • @user136441 - Can you elaborate more on how you installed 5.2.x? Did you append the karmic repo to the current repo list? –  May 01 '13 at 16:19

3 Answers3

7

PHP 5.2 was sent to end of life in December of 2010, so while there's a small chance you might find a PPA or .deb file in some dark alley of the Internet, you're very likely going to have to compile it from source if you want it to run on Ubuntu 12.04. Additionally, it's possible you'll run into problems with dependencies (particularly if anything has changed their API), so keep that in mind.

That said, you can find the latest source for the PHP 5.2 series on their GitHub (I found the 5.2.17 tag for you), and compile it using make. The PHP site also offers information on compiling PHP. The required versions will be different, but it's typically a "this version or greater" unless you get into major release differences (1.0 to 2.0, for example).

As a side note, it might be worth putting pressure on the people that maintain your external application to upgrade to at least the 5.3 series, or better yet, the 5.4 series. There have been a ton of bug fixes and security patches since then. Additionally, most tools don't support 5.2 anymore (which means you don't get things like Xdebug or PHPUnit without a fight, making maintaining an application of decent size and reasonable importance damn near impossible (I've been there)). The upgrade may not be something that can be done right away, thanks to changes between 5.2 and 5.3, but it generates customer demand and helps break down the delusion that a lot of companies have of "well, our userbase doesn't want this, so we're not going to offer it" (even though the reason they don't demand it is because it was absent from the product and they found workarounds, nevermind the fact that if the product offered it, the customers would use it).

Shauna
  • 3,024
  • If you compile php from source you may need to read up on what options you wish to enable (it is a long list). – Panther Feb 28 '13 at 20:50
  • Only will compile php if i cant find a repo on the net. Tks for your help shauna – user136441 Mar 01 '13 at 08:29
  • Used http://old-releases.ubuntu.com/ubuntu/dists/ added karmic repo and have php 5.2.10 installed. – user136441 Mar 04 '13 at 12:07
  • @user136441 - Just fyi, you can answer your own question. So feel free to make that an answer and mark it as the accepted one. – Shauna Mar 04 '13 at 13:47
1

I had never done it on Ubuntu, but yes in Debian Squeeze using the respository of Debian Lenny.

As the packages of PHP are all from Debian I think that this tutorial will server for Ubuntu.

  1. Edit the repository list.

    sudo nano /etc/apt/sources.list
    
  2. Add the next line to ther /etc/apt/sources.list:

    deb http://archive.debian.org/debian-archive/debian/ lenny main contrib non-free
    
  3. Update the information of repos

    sudo apt-get update
    
  4. Edit the preferences of apt...

    sudo nano /etc/apt/preferences.d/php.conf
    
  5. Add the next conf:

    Package: php5*
    Pin: release a=oldstable
    Pin-Priority: 700
    
    Package: *
    Pin: release a=stable
    Pin-Priority: 600
    
  6. Install sudo apt-get install php5 -t oldstable

  7. Check that is the 5.2* version installed

    sudo dpkg -l | grep php5
    

I repeat... not tested... just what i do on Debian ...

Original source: http://www.gustavopilla.com/2012/01/21/php-5-2-en-debian-squeeze/

GusPilla
  • 11
  • 1
  • sudo apt-get install php5 -t oldstable And I got this The following packages have unmet dependencies: php5 : Depends: libapache2-mod-php5 (>= 5.2.6.dfsg.1-1+lenny16) but it is not going to be installed or libapache2-mod-php5filter (>= 5.2.6.dfsg.1-1+lenny16) but it is not going to be installed or php5-cgi (>= 5.2.6.dfsg.1-1+lenny16) but it is not going to be installed N: Ignoring file 'php.conf' in directory '/etc/apt/preferences.d/' as it has an invalid filename extension E: Unable to correct problems, you have held broken packages. – vee May 08 '16 at 09:23
0

Anyone who ends up here should consider following this tutorial.

It explains in details how to compile and setup PHP 5.2 alongside the supported PHP version and how to use in only on the needed vhost.

Flyk
  • 1,480
Jim
  • 1
  • Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – guntbert Feb 23 '14 at 19:27
  • Followed that tutorial can installed php 5.2.17 but many extensions are not installed even it was enabled. – vee May 08 '16 at 09:14