我正在维护 3 个网络服务器,全部运行 Ubuntu 16.04。目前,我们正在尝试在将服务器升级到 18.04 甚至 20.04 之前从 php-memcache 迁移到 php-memcached。
我已经安装成功了php-memcached在 3 个网络服务器中的 1 个上,但另外两个给我一个依赖错误。
# apt-get install php-memcached
[...]
Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been create or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php-memcached: Depends: php-common (>= 1:7.0+33~) but it is not going to be installed
Depends: phpapi-20151012
E: Unable to correct problems, you have held broken packages.
尝试了更新 -> dist-upgrade 并重新启动,但这并没有解决问题。
这些是根据以下内容的存储库apt-get update
:
# apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Fetched 325 kB in 0s (364 kB/s)
看来问题出在 phpapi-20151012 上
# apt-get -o Debug::pkgProblemResolver=yes install phpapi-20151012
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package phpapi-20151012 is a virtual package provided by:
php7.0-phpdbg 7.0.33-0ubuntu0.16.04.15
php7.0-fpm 7.0.33-0ubuntu0.16.04.15
libphp7.0-embed 7.0.33-0ubuntu0.16.04.15
php7.0-cli 7.0.33-0ubuntu0.16.04.15
php7.0-cgi 7.0.33-0ubuntu0.16.04.15
libapache2-mod-php7.0 7.0.33-0ubuntu0.16.04.15
You should explicitly select one to install.
E: Package 'phpapi-20151012' has no installation candidate
据我了解,上述消息 phpapi-20151012 应与列出的软件包之一一起提供。我已经安装了 2 个,但仍然没有 phpapi。所以我尝试安装一个我没有的,但也不起作用。
看来 php-common 包没问题:
# apt-get -o Debug::pkgProblemResolver=yes install php-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-common is already the newest version (1:62+ubuntu14.04.1+deb.sury.org+1).
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
我还注意到 php 7.1 软件包似乎是 Ubuntu 14 的遗留物:
php7.1-cli/now 7.1.19-1+ubuntu14.04.1+deb.sury.org+1 amd64 [installed,local]
php7.1-common/now 7.1.19-1+ubuntu14.04.1+deb.sury.org+1 amd64 [installed,local]
php7.1-json/now 7.1.19-1+ubuntu14.04.1+deb.sury.org+1 amd64 [installed,local]
php7.1-opcache/now 7.1.19-1+ubuntu14.04.1+deb.sury.org+1 amd64 [installed,local]
php7.1-readline/now 7.1.19-1+ubuntu14.04.1+deb.sury.org+1 amd64 [installed,local]
Apache 使用的是 php 7.0,而 cli 使用的是 7.1 ...因此,首先我将 php cli 降级到 7.0:
# update-alternatives --config php
There are 3 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/php7.1 71 auto mode
1 /usr/bin/php5.6 56 manual mode
2 /usr/bin/php7.0 70 manual mode
3 /usr/bin/php7.1 71 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
# update-alternatives --config php
There are 3 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php7.1 71 auto mode
1 /usr/bin/php5.6 56 manual mode
* 2 /usr/bin/php7.0 70 manual mode
3 /usr/bin/php7.1 71 manual mode
Press <enter> to keep the current choice[*], or type selection number:
接下来我删除了 7.1 软件包:
apt-get remove php7.1-cli
apt-get autoremove
之后所有 php7.1 软件包都消失了
然后尝试了这个:
apt-get update --fix-missing
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [802 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [723 kB]
Fetched 1,850 kB in 1s (1,091 kB/s)
Reading package lists... Done
# apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
仍然没有运气......我不知道。有什么建议么?
更新:
按照评论中的要求:
# apt policy php-common
php-common:
Installed: 1:62+ubuntu14.04.1+deb.sury.org+1
Candidate: 1:62+ubuntu14.04.1+deb.sury.org+1
Version table:
*** 1:62+ubuntu14.04.1+deb.sury.org+1 100
100 /var/lib/dpkg/status
1:35ubuntu6.1 500
500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
1:35ubuntu6 500
500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu xenial/main i386 Packages
500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu xenial/main i386 Packages
答案1
至少还有一个 PHP 7.1 软件包的残余,php-common
;您需要将其降级到 Ubuntu 存储库中可用的版本:
apt install php-common=1:35ubuntu6.1