linux - Can't install old version of php


I need to install an old version of php, because I have a website which is based on that version and won't run with the current one. I know that this should not be done, but it will only be online while updating everything.

I followed this guide: but when calling phpinfo(), I get: Version 5.6.24-0+deb8u1.

I also tried to install php via tarball, which worked, but I won't get it to run with apache...

What can I do to achieve that?

Edit: dpkg --list shows me, that I have the following installed:

php5          5.3.10-2
php5-cli      5.6.24+dfsg-
php5-common   5.6.25+dfsg-
php5-json     1.3.6-1
php5-readline 5.6.24+dfsg





So here's the issue in the How To you read: it does not outline every package in the specific version it is actually required. So it (probably) installed the correct PHP version, but not the correct cli version and for sure not the correct apache mod.

I managed to build an apt-get command that installs the correct apache and php version. So with that you have a basic installation (with not that many extensions and stuff) you can go ahead with:

apt-get install php5=5.3.10-2 php5-cli=5.3.10-2 php5-common=5.3.10-2 \
libapache2-mod-php5=5.3.10-2 apache2=2.2.22-1 apache2.2-common=2.2.22-1 \
apache2-mpm-prefork=2.2.22-1 ssl-cert apache2.2-bin=2.2.22-1

How i got there

I want to outline here how i got there for documenation purpose:

I basically startet with thephp5 andphp5-cli package and the run into a lot of apt-get issues that looks like that:

The following packages have unmet dependencies:
 apache2-bin : Conflicts: apache2.2-common but 2.2.22-1 is to be installed
 apache2.2-common : Depends: apache2.2-bin (= 2.2.22-1) but 2.4.7-1ubuntu4.13 is to be installed
 libapache2-mod-php5 : Depends: apache2-mpm-prefork (> 2.0.52) but it is not going to be installed or
                                apache2-mpm-itk but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

The easiest way is then to run amadison to list the available versions and choose the right one (which in your case will probably always be the oldest one):

apt-cache madison apache2-mpm-prefork
apache2-mpm-prefork | 2.4.10-1ubuntu1.1~ubuntu14.04.1 | trusty-backports/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4.13 | trusty-updates/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4.13 | trusty-security/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4 | trusty/main amd64 Packages
apache2-mpm-prefork |   2.2.22-1 | unstable/main amd64 Packages
   apache2 | 2.4.7-1ubuntu4 | trusty/main Sources
   apache2 | 2.4.7-1ubuntu4.13 | trusty-updates/main Sources
   apache2 | 2.4.10-1ubuntu1.1~ubuntu14.04.1 | trusty-backports/main Sources
   apache2 | 2.4.7-1ubuntu4.13 | trusty-security/main Sources
   apache2 |   2.2.22-1 | unstable/main Sources

And just to mention it, this is Apache 2.2 going to be installed. I have no idea how supported that still is, but I am sure that PHP 5.3 is way to old. You might expose yourself to quite a huge security issue.

People are also looking for solutions to the problem: php - wp_cron schedulestops working after some period of time


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.