我使用命令从我的电脑上卸载了 php5
sudo apt-get -y purge php.*
运行此命令将在终端中显示此消息:
Errors were encountered while processing: php5-memcache php5-memcached
因此我尝试卸载 memcache:
sudo apt-get remove php-memcache
它向我显示了一条消息,提示我找不到 memcache 包:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php-memcache
然后是 memcached:
apt-get remove php5-memcached
它向我抛出了有关 php 中缺少依赖项的信息:
The following packages have unmet dependencies.
php5-memcache : Depends: php5-common (>= 4.3.11) but it is not going to be installed
Depends: php-pear (>= 1.4.0~b1) but it is not going to be installed
Depends: phpapi-20121212
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
跑步
apt-get -f install
再次向我抛出有关删除 memcache 的错误。
我理解的没错,我犯了一个错误,在卸载 php5 之前没有删除 memcache?我现在该怎么办?我需要再次安装 php 吗?当我尝试安装缺少的依赖项时,我收到有关另一个缺少软件包的消息。使用“apt-get”时,不应该自动添加/删除缺少的软件包吗?
通过谷歌搜索,我发现问题可能是由于使用了错误的存储库,这些存储库不适合我的系统。我如何检测哪些存储库适合我的系统以安装/卸载适当的软件包来卸载 memcache?谢谢您的帮助
我的系统中添加了这样的 php 存储库: http://ppa.launchpad.net/ondrej/php5/ubuntu http://ppa.launchpad.net/ondrej/php5/ubuntu http://ppa.launchpad.net/ondrej/php-7.0/ubuntu http://ppa.launchpad.net/ondrej/php-7.0/ubuntu
我尝试按照@oerdnj 的建议使用 dpkg 删除 memcache,但仍然收到一些错误:
tomas@Toshiba ~ $ sudo dpkg --purge php5-memcache
(Reading database ... 275094 files and directories currently installed.)
Removing php5-memcache (3.0.8-4build1) ...
/var/lib/dpkg/info/php5-memcache.prerm: 9: /var/lib/dpkg/info/php5- memcache.prerm: php5dismod: not found
dpkg: error processing package php5-memcache (--purge):
subprocess installed pre-removal script returned error exit status 127
Errors were encountered while processing:
php5-memcache
我也尝试过从线程中解决如何删除/安装未完全安装的软件包? 但它显示了同样的错误:
tomas@Toshiba ~ $ sudo apt-get install --reinstall dpkg
[sudo] password for tomas:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies.
php5-memcache : Depends: php5-common (>= 4.3.11) but it is not going to be installed
Depends: php-pear (>= 1.4.0~b1) but it is not going to be installed
Depends: phpapi-20121212
php5-memcached : Depends: libmemcached10 but it is not going to be installed
Depends: php5-common (>= 5.2.0) but it is not going to be installed
Depends: php5-common (< 6.0.0) but it is not going to be installed
Depends: php-pear (>= 1.4.0~b1) but it is not going to be installed
Depends: phpapi-20121212
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
答案1
如果您的系统处于apt-get
几乎无法使用的状态,您可以尝试dpkg
删除受影响的软件包,在这种情况下尝试:
sudo dpkg --purge php5-memcache
dpkg
是一种操作包的低级工具,它并不会竭力让所有包保持一致状态。
由于php5dismod
您的系统中缺少,我建议您删除/var/lib/dpkg/info/php5-memcache.prerm
和/var/lib/dpkg/info/php5-memcache.postrm
文件并/etc/php5/
手动清理 memcache 配置的痕迹(可能在那里找到主要的memcache.ini
符号链接20-memcache.ini
)。
注意:请不要尝试互联网上的其他随机事物,如果您不完全了解自己在做什么,您可能会进一步破坏系统。
答案2
我从 Ubuntu 14.04 更新到 Ubuntu 16.04 后遇到了这个问题。
如果你打开var/lib/dpkg/info/php5-memcached.prerm
你会看到这样的内容:
#!/bin/sh
set -e
dpkg-maintscript-helper mv_conffile /etc/php5/conf.d/memcached.ini \
/etc/php5/mods-available/memcached.ini 2.0.1-3 -- "$@"
rm -f /etc/php5/conf.d/memcached.ini
[ "$1" = "remove" ] && php5dismod memcached
exit 0
修复该错误的最简单方法就是注释掉该php5dismod
行:
#!/bin/sh
set -e
dpkg-maintscript-helper mv_conffile /etc/php5/conf.d/memcached.ini \
/etc/php5/mods-available/memcached.ini 2.0.1-3 -- "$@"
rm -f /etc/php5/conf.d/memcached.ini
# !!!!!!!!!!
# Do _not_ do anything with php5dismod
# [ "$1" = "remove" ] && php5dismod memcached
# !!!!!!!!!!
exit 0
此后,您可以sudo apt-get -f install
再次运行,它会将其删除,不会出现问题。