36

I've just installed Ubuntu 14.04 and am trying to install php 5.3. But when I run

apt-get install php5 

it's installing php 5.5.9-1ubuntu4. I need to use php 5.3 in the system because the application I'm working on is built with php 5.3.

How can I achieve this?

Sourav Ghosh
  • 401
  • 4
  • 13
  • 1
    do you need php 5.3 or php 5.5.3 ? –  May 08 '14 at 05:43
  • i need php 5.3 since its being used the app i'm working. – Chathruaka Waas May 08 '14 at 09:23
  • 2
    You need to use the latest PHP version because the previous one are obsoletes. – Lucio May 24 '14 at 16:43
  • 8
    Save yourself the misery & switch back to 12.04 - From your comments I understand that you have a project using PHP 5.3, from my experience, I had the same issue when I moved to 14.04. All my CakePHP projects failed to work. All the suggestions given here do work, I was able to install PHP 5.3 by manually building it as answered by @raaz. But trust me even if you successfully install PHP 5.3 it will have a lot of dependency issues with other packages & services like apache, mysql etc. I wasted 2 days in trying to make things work, but finally I switched back to 12.04. Note:- For the question t – Nitish Dhar May 24 '14 at 16:38
  • @NitishDhar I wasted 3 days on setting up my legacy PHP project on Ubuntu 20. Your comment makes much sense. BTW I'm using WSL within Windows machine. Is there any option to downgrade Ubuntu on WSL? – Mdumanoj Sep 15 '22 at 14:51

4 Answers4

25

Pre-requisites

You will need these two extra packages if you don't have them:

sudo apt-get install build-essential libxml2-dev

Install PHP

In terminal:

wget http://in1.php.net/distributions/php-5.3.29.tar.bz2
tar -xvf php-5.3.29.tar.bz2
cd php-5.3.29
./configure
make
make test # Neither mandatory nor a bad idea.
sudo make install

The instructions will untar the source build and they will install php in your system.

msanford
  • 229
Raja G
  • 102,391
  • 106
  • 255
  • 328
9

You can use Eugene San PPA for install php 5.3 in ubuntu 14.04.

Follow these steps:

sudo add-apt-repository ppa:eugenesan/ppa

sudo apt-get update

sudo apt-get install php5
  • followed the instructions and the result was this. dpkg: dependency problems prevent configuration of php5: php5 depends on libapache2-mod-php5 (>= 5.3.2-1ubuntu4) | libapache2-mod-php5filter (>= 5.3.2-1ubuntu4) | php5-cgi (>= 5.3.2-1ubuntu4); however: Package libapache2-mod-php5 is not installed. Package libapache2-mod-php5filter is not installed. Package php5-cgi is not installed.

    dpkg: error processing package php5 (--install): dependency problems - leaving unconfigured Errors were encountered while processing: php5

    – Chathruaka Waas May 08 '14 at 07:39
  • Follow the edit and see. –  May 08 '14 at 08:12
  • 3
    Doesn't work. I've tried, but in the end it still installed 5.5.9 – Eugene Apr 03 '15 at 21:57
  • 2
    It's not work.. – KyungHoon Kim Sep 01 '15 at 16:07
  • 3
    You can use ppa:sergey-dryabzhinsky/php53 instead. – nnyby Nov 04 '15 at 19:55
  • In this repository there isn't php53-mod-memcache any idea to setup php53 with memcache module? – ChoiZ Apr 22 '16 at 14:46
  • 1
    for memcached add ppa:sergey-dryabzhinsky/php53-modules – Hubisan Aug 18 '16 at 09:26
  • are these repo's are still alive? – Ali Shan Feb 19 '18 at 21:05
  • How to install php-mysql module? It's showing unable to locate package – Mdumanoj Sep 15 '22 at 12:16
5

This needs to be said over and over: Don't run outdated software.

PHP 5.3 has reached its end-of-life on 14 Aug 2014, that's 1 year and 8 months ago at the time of writing this answer.

Using outdated end-of-life software will bring you nothing but pain and security vulnerabilities, unless you can invest a time to properly research all existing security vulnerabilities against PHP since the last PHP 5.3.x release and carefully cherry-pick security fixes from more recent PHP releases yourself.

I would definitely recommend to fix the software that requires PHP 5.3 instead, by following the PHP migration guides:

And I would even recommend going straight to PHP 5.6 (or even PHP 7.0) as it will have security support until 31 Dec 2018. The migration guides are here:

The code migration to newer PHP code might seem like a big investment, but in the end this will save you time and money as running outdated software is a serious security risk, especially when interfaced with the big-bad-Internet, but even running it firewalled inside the limited network poses a security risk when your internal network is attacked.

The second option would be to use Ubuntu 12.04 LTS that has PHP 5.3.10-1ubuntu3.22 with security patches prepared by Canonical maintainers. You might think that 5.3.10 is less than 5.3.29, but the fact is that the PHP version in Ubuntu 12.04 LTS has less (serious) security vulnerabilities than vanilla upstream PHP 5.3.29, because the Ubuntu maintainers of PHP are watching the security vulnerabilities and patching PHP to mitigate the serious vulnerabilities in the packages.

oerdnj
  • 7,940
  • 18
    In a perfect world yes, but unfortunately sometimes you need to replicate a legacy server that's out of date and out of your hands. In order to mock the production environment virtually you need to be able to install legacy packages.

    Then once you have a mocked 1:1 testing environment, then you can begin the updating process (if applicable to your scenario).

    – Dylan Pierce Aug 29 '16 at 16:01
  • 1
    An example of this is php source code that has been encoded with an old version of ioncube. You must install the old php and loader versions. – Dominic Cerisano Nov 09 '17 at 20:03
  • Not useful advice for people who upgrade legacy PHP apps for a living. It's really tiresome to hear about the need to upgrade when a critical step of the upgrade is running the original code and write characterization tests for them. – afilina Apr 17 '23 at 14:42
0

In case you really need to do it, use phpbrew.

My steps to install php5.3 on Ubuntu 16.04 (will work for 14.04):

https://bitbucket.org/snippets/sergiy_opentag/4LLrMR