我在 docker container 中使用 Debian Jessie docker run --entrypoint /bin/bash -i -t php:5-apache
。不幸的是,我无法安装 php5-mysql 或 php5-mysqlnd 。我做了以下步骤:
apt-get update
Hit http://security.debian.org jessie/updates InRelease
Get:1 http://security.debian.org jessie/updates/main amd64 Packages [641 kB]
Ign http://deb.debian.org jessie InRelease
Hit http://deb.debian.org jessie-updates InRelease
Hit http://deb.debian.org jessie Release.gpg
Get:2 http://deb.debian.org jessie-updates/main amd64 Packages [23.1 kB]
Hit http://deb.debian.org jessie Release
Get:3 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 9728 kB in 45s (215 kB/s)
Reading package lists... Done
apt-get install php5-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5-mysql is a virtual package provided by:
php5-mysqlnd 5.6.33+dfsg-0+deb8u1 [Not candidate version]
php5-mysqlnd 5.6.30+dfsg-0+deb8u1 [Not candidate version]
E: Package 'php5-mysql' has no installation candidate
apt-get install php5-mysqlnd
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5-mysqlnd is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
php5-mysql
E: Package 'php5-mysqlnd' has no installation candidate
我错过了什么?
迈克尔
如果您使用的是Docker PHP5-apache 映像,那么所描述的行为很可能是由 APT 首选项文件 /etc/apt/preferences.d/no-debian-php 引起的。其中的内容似乎阻止了 APT 考虑任何与 PHP 相关的包。
您正在使用的 docker 映像提供了一个源构建的 PHP,APT PHP 包在这里不会帮助您。如果您需要为 docker 镜像中安装的 PHP 添加扩展,您应该使用文档中描述的帮助脚本从源代码构建。