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?

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

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.

  • 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. – Chathruaka Waas May 8 '14 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 '14 at 8:14
  • 3
    Use apt-get install libxml2-dev – complex Sep 3 '14 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 – Jacob Minshall Sep 13 '14 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 '14 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
  • 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 8 '14 at 7:39
  • Follow the edit and see. – user224082 May 8 '14 at 8:12
  • 3
    Doesn't work. I've tried, but in the end it still installed 5.5.9 – Eugene Apr 3 '15 at 21:57
  • 2
    It's not work.. – KyungHoon Kim Sep 1 '15 at 16:07
  • 2
    You can use ppa:sergey-dryabzhinsky/php53 instead. – nnyby Nov 4 '15 at 19:55
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.

  • 16
    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
  • 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 9 '17 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

protected by Community Aug 20 '14 at 5:47

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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