无法安装旧版本 php

Can't install old version of php

我需要安装旧版本的 php,因为我有一个基于该版本的网站,不会 运行 使用当前版本。我知道这不应该做,但它只会在更新所有内容时在线。

我遵循了这个指南:http://mstd.eu/index.php/2016/07/04/install-old-versions-of-software-on-debian-like-php-5-3/ 但是当调用 phpinfo() 时,我得到:版本 5.6.24-0+deb8u1.

我也尝试通过 tarball 安装 php,这很有效,但我不会用 apache 将它安装到 运行...

我该怎么做才能实现这一目标?

编辑:dpkg --list 显示我安装了以下软件:

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-

TL;DR

所以这就是您阅读的方法中的问题:它没有概述实际需要的特定版本中的每个包。所以它(可能)安装了正确的 PHP 版本,但没有安装正确的 cli 版本,当然也没有安装正确的 apache mod.

我设法构建了一个安装正确的 apache 和 php 版本的 apt-get 命令。所以你有了一个基本的安装(没有那么多扩展和东西)你可以继续:

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

我是怎么到那里的

我想在这里概述一下我是如何到达那里进行记录的:

我基本上是从 php5php5-cli 包和 运行 开始的,遇到了很多看起来像这样的 apt-get 问题:

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.

然后最简单的方法是 运行 madison 列出可用版本并选择正确的版本(在您的情况下,它可能永远是最旧的版本):

apt-cache madison apache2-mpm-prefork
apache2-mpm-prefork | 2.4.10-1ubuntu1.1~ubuntu14.04.1 | http://us.archive.ubuntu.com/ubuntu/ trusty-backports/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4.13 | http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4.13 | http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
apache2-mpm-prefork | 2.4.7-1ubuntu4 | http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
apache2-mpm-prefork |   2.2.22-1 | http://snapshot.debian.org/archive/debian/20120221T041601Z/ unstable/main amd64 Packages
   apache2 | 2.4.7-1ubuntu4 | http://us.archive.ubuntu.com/ubuntu/ trusty/main Sources
   apache2 | 2.4.7-1ubuntu4.13 | http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main Sources
   apache2 | 2.4.10-1ubuntu1.1~ubuntu14.04.1 | http://us.archive.ubuntu.com/ubuntu/ trusty-backports/main Sources
   apache2 | 2.4.7-1ubuntu4.13 | http://security.ubuntu.com/ubuntu/ trusty-security/main Sources
   apache2 |   2.2.22-1 | http://snapshot.debian.org/archive/debian/20120221T041601Z/ unstable/main Sources

顺便提一下,这是要安装的 Apache 2.2。我不知道它的支持程度如何,但我确信 PHP 5.3 已经过时了。您可能会面临相当大的安全问题。