我的生产环境有 php7.0.18-0ubuntu0.16.04.1,我正在尝试安装一个新模块(php7.0-bcmath),但找不到在已有的 php 版本上安装它的方法
$ apt-cache policy php7.0
php7.0:
Installed: 7.0.18-0ubuntu0.16.04.1
Candidate: 7.0.22-0ubuntu0.16.04.1
Version table:
7.0.22-0ubuntu0.16.04.1 500
500 http://nova.clouds.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
*** 7.0.18-0ubuntu0.16.04.1 100
100 /var/lib/dpkg/status
7.0.4-7ubuntu2 500
500 http://nova.clouds.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
$
7.0.18看起来像是带有ubuntu安装的版本包。
bcmath 的政策:
$ apt-cache policy php7.0-bcmath
php7.0-bcmath:
Installed: (none)
Candidate: 7.0.22-0ubuntu0.16.04.1
Version table:
7.0.22-0ubuntu0.16.04.1 500
500 http://nova.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages
7.0.4-7ubuntu2 500
500 http://nova.clouds.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
$
如果我尝试安装 bcmath,我也会更新 php
$ sudo apt-get -s install php7.0-bcmath
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-fpm php7.0-json php7.0-mbstring php7.0-mysql php7.0-opcache php7.0-readline php7.0-xml php7.0-zip
Suggested packages:
php-pear
The following NEW packages will be installed:
php7.0-bcmath
The following packages will be upgraded:
php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-fpm php7.0-json php7.0-mbstring php7.0-mysql php7.0-opcache php7.0-readline php7.0-xml php7.0-zip
12 upgraded, 1 newly installed, 0 to remove and 93 not upgraded.
Inst php7.0-mysql [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-xml [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-json [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-zip [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-curl [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-mbstring [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-opcache [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-readline [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-fpm [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0-cli [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64]) []
Inst php7.0 [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [all]) []
Inst php7.0-common [7.0.18-0ubuntu0.16.04.1] (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Inst php7.0-bcmath (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-common (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-mysql (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-xml (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-json (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-zip (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-curl (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-mbstring (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-opcache (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-readline (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-cli (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0-fpm (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
Conf php7.0 (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [all])
Conf php7.0-bcmath (7.0.22-0ubuntu0.16.04.1 Ubuntu:16.04/xenial-updates, Ubuntu:16.04/xenial-security [amd64])
$
如果我尝试强制一个版本:
$ sudo apt-get -s install php7.0-bcmath=7.0.18-0ubuntu0.16.04.1
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '7.0.18-0ubuntu0.16.04.1' for 'php7.0-bcmath' was not found
$
我知道升级到 php7.0.22 是一个(好的)解决方案,但是有没有办法只安装这个模块而不会在升级 php 时产生停机时间?
答案1
我通过下载 .deb 包解决了这个问题
$ wget http://launchpadlibrarian.net/319286878/php7.0-bcmath_7.0.18-0ubuntu0.16.04.1_amd64.deb
--2017-09-27 16:11:01-- http://launchpadlibrarian.net/319286878/php7.0-bcmath_7.0.18-0ubuntu0.16.04.1_amd64.deb
Resolving launchpadlibrarian.net (launchpadlibrarian.net)... 91.189.89.228, 91.189.89.229
Connecting to launchpadlibrarian.net (launchpadlibrarian.net)|91.189.89.228|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15726 (15K) [application/x-debian-package]
Saving to: ‘php7.0-bcmath_7.0.18-0ubuntu0.16.04.1_amd64.deb’
php7.0-bcmath_7.0.18-0ubuntu0.16.04.1_amd64.deb 100%[====================================================================================================================================>] 15.36K --.-KB/s in 0.007s
2017-09-27 16:11:01 (2.09 MB/s) - ‘php7.0-bcmath_7.0.18-0ubuntu0.16.04.1_amd64.deb’ saved [15726/15726]
$
并安装它...
$ sudo dpkg -i php7.0-bcmath_7.0.18-0ubuntu0.16.04.1_amd64.deb
Selecting previously unselected package php7.0-bcmath.
(Reading database ... 127511 files and directories currently installed.)
Preparing to unpack php7.0-bcmath_7.0.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking php7.0-bcmath (7.0.18-0ubuntu0.16.04.1) ...
Setting up php7.0-bcmath (7.0.18-0ubuntu0.16.04.1) ...
Creating config file /etc/php/7.0/mods-available/bcmath.ini with new version
Processing triggers for php7.0-fpm (7.0.18-0ubuntu0.16.04.1) ...
$
简单快捷
$ apt-cache policy php7.0-bcmath
php7.0-bcmath:
Installed: 7.0.18-0ubuntu0.16.04.1
Candidate: 7.0.22-0ubuntu0.16.04.1
Version table:
7.0.22-0ubuntu0.16.04.1 500
500 http://nova.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages
*** 7.0.18-0ubuntu0.16.04.1 100
100 /var/lib/dpkg/status
7.0.4-7ubuntu2 500
500 http://nova.clouds.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
$