我刚刚安装了一个php 5.5的新服务器。然而,我的一个老项目需要PHP 5.3。
所以我安装了php 5.3和wget http://www.php.net/get/php-5.3.28.tar.bz2/from/a/mirror
tar -xvjf mirror
cd php-5.3.28
./configure --prefix /usr/local/php.5.3.28
make
make install
然而php_mysql和php_pdo_mysql扩展丢失。所以我想知道如何将它们安装到一个自定义php构建与多个php版本运行的服务器上?
服务器运行在ubuntu 14.04
最近我不得不迁移带有非常旧的php代码的服务器,这些代码需要php 5.3版本才能运行。因为我的虚拟机供应商使用的是最新最好的,并且有一个政策,不允许使用旧的linux发行版,所以我不得不使用Ubuntu 14.04。问题是,正如您所说,它是随php 5.5一起发布的,所以我必须想出一种方法,使我能够启动并运行php 5.3。在互联网上搜索了一段时间后,我发现了各种各样的解决方案,我尝试了第一个是你从源代码安装的。确实安装了php 5.3,但后来我遇到了同样的问题,你似乎有,所以我尝试了另一种解决方案,建议使用CGI来支持php 5.3。我以为我已经找到了这个难题的最终解决方案,但一段时间后,我意识到它非常不稳定,而且有很多bug。所以我想到了如何解决这个问题,这是我想到的。在我展示如何在我的Ubuntu 14.04上正确安装php 5.3之前,我想说的是,这可能不是最优雅的方法,但我花了这么多时间在一个本应简单的任务上,现在回想起来,这是一个公平的解决方案。总之是这样的:
$ cd /etc/apt/
$ sudo cp sources.list sources.list.14_04
使用您最喜欢的编辑器和编辑源。列出并删除文件的内容,然后将以下内容粘贴到您的文件中(这是一个源代码。
# deb cdrom:[Ubuntu-Server 12.04.1 LTS _Precise Pangolin_ - Release amd64 (20120817.3)]/ dists/precise/main/binary-i386/
# deb cdrom:[Ubuntu-Server 12.04.1 LTS _Precise Pangolin_ - Release amd64 (20120817.3)]/ dists/precise/restricted/binary-i386/
# deb cdrom:[Ubuntu-Server 12.04.1 LTS _Precise Pangolin_ - Release amd64 (20120817.3)]/ precise main restricted
#deb cdrom:[Ubuntu-Server 12.04.1 LTS _Precise Pangolin_ - Release amd64 (20120817.3)]/ dists/precise/main/binary-i386/
#deb cdrom:[Ubuntu-Server 12.04.1 LTS _Precise Pangolin_ - Release amd64 (20120817.3)]/ dists/precise/restricted/binary-i386/
#deb cdrom:[Ubuntu-Server 12.04.1 LTS _Precise Pangolin_ - Release amd64 (20120817.3)]/ precise main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ precise main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://us.archive.ubuntu.com/ubuntu/ precise universe
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner
## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
# deb http://extras.ubuntu.com/ubuntu precise main
# deb-src http://extras.ubuntu.com/ubuntu precise main
现在保存并退出。
$ sudo apt-get clean
$ sudo apt-get check
$ sudo apt-get update
$ sudo apt-get install php5 php-mysql
Install whatever package you want to work with php version 5.3
$ php -version
PHP 5.3.10-1ubuntu3.19 with Suhosin-Patch (cli) (built: Jul 2 2015 15:05:04)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
如果你需要安装mysql-server,你将不得不切换回你的源代码。列表到源列表。14 _04文件
$ sudo mv sources.list sources.list.12_04
$ sudo mv sources.list.14_04 sources.list
$ sudo apt-get clean
$ sudo apt-get check
$ sudo apt-get update
除此之外,你应该有一个Ubuntu 14.04, php版本5.3和php_mysql扩展运行良好。