35

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?

5
  • 1
    do you need php 5.3 or php 5.5.3 ?
    – user224082
    May 8, 2014 at 5:43
  • i need php 5.3 since its being used the app i'm working. May 8, 2014 at 9:23
  • 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 May 24, 2014 at 16:38
  • 2
    You need to use the latest PHP version because the previous one are obsoletes.
    – Lucio
    May 24, 2014 at 16:43
  • @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 at 14:51

4 Answers 4

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.

12
  • resulted giving an error when using the make command. root@Chathuraka-Dell:~/php-5.3.28# make make: *** No targets specified and no makefile found. Stop. root@Chathuraka-Dell:~/php-5.3.28# make install make: *** No rule to make target `install'. Stop. May 8, 2014 at 7:43
  • @ChathruakaWaas what you have got after doing ./configure ? i need that log . use pastebin and give me link
    – rɑːdʒɑ
    May 8, 2014 at 8:14
  • 3
    Use apt-get install libxml2-dev
    – complex
    Sep 3, 2014 at 13:19
  • 2
    it worked fine for me, but who knows what extra libraries I have on my system... Though one thing I did differently was I didn't use sudo until the make install command. That's the only time something needs sudo Sep 13, 2014 at 23:45
  • 3
    Also since i already had php5 installed I had to sudo apt-get purge php5 && sudo apt-get install libxml2-dev
    – jmunsch
    Sep 25, 2014 at 18:12
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
9
  • 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 May 8, 2014 at 7:39
  • 3
    Doesn't work. I've tried, but in the end it still installed 5.5.9
    – Eugene
    Apr 3, 2015 at 21:57
  • 2
    It's not work.. Sep 1, 2015 at 16:07
  • 3
    You can use ppa:sergey-dryabzhinsky/php53 instead.
    – nnyby
    Nov 4, 2015 at 19:55
  • 1
    for memcached add ppa:sergey-dryabzhinsky/php53-modules
    – Hubisan
    Aug 18, 2016 at 9:26
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.

2
  • 17
    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). Aug 29, 2016 at 16:01
  • 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. Nov 9, 2017 at 20:03
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

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