安装 php-cli 时出现问题

安装 php-cli 时出现问题

我正在尝试在我的计算机上安装 php5-cli 包,但是由于未满足依赖关系而出现以下错误。

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:
 libmaven2-core-java : Depends: libdoxia-core-java (>= 1.1) but it is not going to be installed
 php5-cli : Depends: libonig2 (>= 5.9.5) but it is not going to be installed
            Depends: libqdbm14 (>= 1.8.74) but it is not going to be installed
            Depends: php5-common (= 5.6.12+dfsg-1+deb.sury.org~vivid+1) but it is not going to be installed
            Depends: php5-json but it is not going to be installed
            Recommends: php5-readline but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我尝试过 apt-get install -f、apt-get clean 和 apt-get autoclean,但都没有用。我尝试过这篇文章中给出的几乎所有解决方案添加 PPA 后如何解决未满足的依赖关系?但对我来说它们似乎都不起作用。

编辑:我尝试使用以下方法单独安装软件包

sudo apt-get install php5-readline php5-json php5-common libqdbm14 libonigia-core-java libmaven2-core-java 2 libdox

但这似乎也不起作用。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libonig2 is already the newest version.
libmaven2-core-java is already the newest version.
libmaven2-core-java set to manually installed.
libqdbm14 is already the newest version.
php5-common is already the newest version.
php5-json is already the newest version.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 php5-readline : Depends: php5-cli (= 5.6.12+dfsg-1+deb.sury.org~vivid+1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

以下是 apt-cache policy php5-readline 的输出

php5-readline:
  Installed: (none)
  Candidate: 5.6.12+dfsg-1+deb.sury.org~vivid+1
  Version table:
     5.6.12+dfsg-1+deb.sury.org~vivid+1 0
        500 http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/ vivid/main amd64 Packages
     5.6.12+dfsg-1 0
        500 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
     5.6.4+dfsg-4ubuntu6.2 0
        500 http://pk.archive.ubuntu.com/ubuntu/ vivid-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ vivid-security/main amd64 Packages
     5.6.4+dfsg-4ubuntu6 0
        500 http://pk.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages

输出 grep -r 'ftp.us.debian.org' /etc/apt/ and apt-cache policy libmaven2-core-java

/etc/apt/sources.list:deb http://ftp.us.debian.org/debian unstable main contrib non-free
/etc/apt/sources.list.save:deb http://ftp.us.debian.org/debian unstable main contrib non-free
/etc/apt/sources.list.bak:deb http://ftp.us.debian.org/debian unstable main contrib non-free
grep: and: No such file or directory
grep: apt-cache: No such file or directory
grep: policy: No such file or directory
grep: libmaven2-core-java: No such file or directory

这是脚本的输出:

alsa-base http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
cgroupfs-mount http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
curl http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
dmsetup http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
dnsmasq-base http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libarchive13 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libcurl3-gnutls http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libdevmapper1.02.1 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libeclipse-aether-java http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libgnutls-deb0-28 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libgnutls-deb0-28 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libgnutls-openssl27 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libgrpc-dev http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libgrpc0 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libhogweed4 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libhogweed4 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libjsch-java http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libnettle6 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libnettle6 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
librtmp1 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
librtmp1 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libsisu-inject-java http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libssh2-1 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libssl-dev http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libssl1.0.0 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libssl1.0.0 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libtasn1-6 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libtasn1-6 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libunwind8 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libwagon-java http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
libwagon2-java http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
pepperflashplugin-nonfree http://ftp.us.debian.org/debian/ unstable/contrib amd64 Packages

输出apt-cache policy libmaven2-core-java

libmaven2-core-java:
  Installed: 2.2.1-22
  Candidate: 2.2.1-22
  Version table:
 *** 2.2.1-22 0
        500 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
        100 /var/lib/dpkg/status
     2.2.1-17 0
        500 http://archive.ubuntu.com/ubuntu/ vivid/universe amd64 Packages

我按照答案中的步骤操作,删除了存储库,运行了 apt-get -f install,并且必须执行自动删除来删除一些不再需要的包。它似乎已经解决了 libmaven2-core-java 的问题。然后我尝试再次安装 php5-cli,但得到了以下输出。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
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 created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php5-cli : Depends: php5-common (= 5.6.4+dfsg-4ubuntu6.2) but 5.6.12+dfsg-1+deb.sury.org~vivid+1 is to be installed
            Recommends: php5-readline but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

输出到 sudo apt-get install -f

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded

并输出到 sudo apt-get install php5-cli

Reading package lists... Done
Building dependency tree       
Reading state information... Done
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 created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php5-cli : Depends: php5-common (= 5.6.4+dfsg-4ubuntu6.2) but 5.6.12+dfsg-1+deb.sury.org~vivid+1 is to be installed
            Recommends: php5-readline but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

apt-cache policy php5-common 的输出

php5-common:
  Installed: 5.6.12+dfsg-1+deb.sury.org~vivid+1
  Candidate: 5.6.12+dfsg-1+deb.sury.org~vivid+1
  Version table:
 *** 5.6.12+dfsg-1+deb.sury.org~vivid+1 0
        100 /var/lib/dpkg/status
     5.6.4+dfsg-4ubuntu6.2 0
        500 http://archive.ubuntu.com/ubuntu/ vivid-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ vivid-security/main amd64 Packages
     5.6.4+dfsg-4ubuntu6 0
        500 http://archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages

dpkg -l | grep 'sury' 的输出是

ii  php5-json                                            1.3.7-1+deb.sury.org~vivid+1               amd64        JSON module for php5

答案1

您启用了不兼容的软件存储库。我们可以修复此问题…

  1. 使用 Ubuntu 存储库的主服务器

    sudo sed -i.bak 's/http:\/\/pk\./http:\/\//' /etc/apt/sources.list
    sudo apt-get update
    
  2. 安装ppa-purge

    sudo apt-get install ppa-purge
    

    如果无法安装且未ppa-purge安装,请下载 deb 包

    cd ..
    wget http://mirrors.kernel.org/ubuntu/pool/universe/p/ppa-purge/ppa-purge_0.2.8+bzr57_all.deb
    

    提取并复制可执行文件

    dpkg -x ppa-purge_0.2.8+bzr57_all.deb ppa-purge
    sudo cp ppa-purge/usr/sbin/ppa-purge /usr/sbin
    
  3. 清除 PPA ppa:ondrej/php5-5.6

    sudo ppa-purge ppa:ondrej/php5-5.6
    sudo apt-get update
    
  4. 下一条错误消息

    libmaven2-core-java : Depends: libdoxia-core-java (>= 1.1) but it is not going to be installed
    

    您使用额外的 Debian 存储库http://ftp.us.debian.org/。此存储库提供libmaven2-core-java依赖于 的版本libdoxia-core-java。但此软件包不可用。

    http://ftp.us.debian.org/因此,删除你的存储库/etc/apt/sources.list。之后,运行

    sudo apt-get update
    

    并使用以下命令降级软件包:

    sudo apt-get install libmaven2-core-java=2.2.1-17
    
  5. ppa:ondrej/php5-5.6通常在使用清除 PPA 后不需要ppa-purge,但你的情况也要降级dpkg -l | grep 'sury'

    sudo apt-get install php5-common=5.6.4+dfsg-4ubuntu6.2 
    sudo apt-get install php5-json=1.3.2-2build1
    
  6. 修复安装

    sudo apt-get install -f
    

相关内容