升级时 PHP5 未满足的依赖关系

升级时 PHP5 未满足的依赖关系

尝试使用以下命令将 PHP 从 5.3 升级到 5.6:

sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get install php5-common

当我尝试此操作时,我遇到此错误并且不确定如何解决:

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:
 libapache2-mod-php5 : Depends: apache2-api-20120211
                       Depends: apache2 (>= 2.4)
                       Depends: php5-json
 php5-cli : Depends: php5-common (= 5.3.10-1ubuntu3.21) but 5.6.18+dfsg-1+deb.sury.org~precise+1 is to be installed
 php5-common : Breaks: php5-xdebug (< 2.2.2) but 2.1.0-1 is to be installed
 php5-curl : Depends: php5-common (= 5.3.10-1ubuntu3.21) but 5.6.18+dfsg-1+deb.sury.org~precise+1 is to be installed
 php5-gd : Depends: php5-common (= 5.3.10-1ubuntu3.21) but 5.6.18+dfsg-1+deb.sury.org~precise+1 is to be installed
 php5-intl : Depends: php5-common (= 5.3.10-1ubuntu3.21) but 5.6.18+dfsg-1+deb.sury.org~precise+1 is to be installed
 php5-mysqlnd : Depends: php5-common (= 5.3.10-1ubuntu3.21) but 5.6.18+dfsg-1+deb.sury.org~precise+1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

如果我尝试通过执行以下操作进行升级sudo apt-get install python-software-properties,则会出现此错误:

The following packages have unmet dependencies:
 libapache2-mod-php5 : Depends: apache2-api-20120211
                       Depends: apache2 (>= 2.4)
                       Depends: php5-common (= 5.6.18+dfsg-1+deb.sury.org~precise+1) but 5.3.10-1ubuntu3.21 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

如果我尝试sudo apt-get apache2,我会收到此错误:

The following packages have unmet dependencies:
 apache2 : Depends: apache2-bin (= 2.4.16-4+deb.sury.org~precise+4) but it is not going to be installed
           Depends: apache2-utils (>= 2.4)
           Depends: apache2-data (= 2.4.16-4+deb.sury.org~precise+4) but it is not going to be installed
           Conflicts: apache2.2-bin but 2.2.22-1ubuntu1.10 is to be installed
           Conflicts: apache2.2-common but 2.2.22-1ubuntu1.10 is to be installed
 libapache2-mod-php5 : Depends: apache2-api-20120211
                       Depends: php5-common (= 5.6.18+dfsg-1+deb.sury.org~precise+1) but 5.3.10-1ubuntu3.21 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我尝试sudo apt-get -f install按照建议操作,但问题并未解决。相反,我得到了以下信息:

The following extra packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils dh-php5 libedit2 libgd3 libmemcached11 libvpx1 php5-cli php5-common php5-curl php5-dev php5-gd php5-intl php5-json php5-mcrypt php5-memcached php5-mysqlnd php5-xdebug pkg-php-tools
Suggested packages:
  www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom libgd-tools php5-user-cache dh-make
Recommended packages:
  php5-readline
The following packages will be REMOVED:
  apache2-mpm-prefork apache2.2-bin apache2.2-common
The following NEW packages will be installed:
  apache2-bin apache2-data dh-php5 libgd3 libmemcached11 libvpx1 php5-json pkg-php-tools
The following packages will be upgraded:
  apache2 apache2-utils libedit2 php5-cli php5-common php5-curl php5-dev php5-gd php5-intl php5-mcrypt php5-memcached php5-mysqlnd php5-xdebug
13 upgraded, 8 newly installed, 3 to remove and 10 not upgraded.
8 not fully installed or removed.
Need to get 0 B/7,060 kB of archives.
After this operation, 3,685 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 149017 files and directories currently installed.)
Unpacking apache2-bin (from .../apache2-bin_2.4.16-4+deb.sury.org~precise+4_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/apache2-bin_2.4.16-4+deb.sury.org~precise+4_amd64.deb (--unpack):
 trying to overwrite '/usr/share/man/man8/apache2.8.gz', which is also in package apache2.2-common 2.2.22-1ubuntu1.10
dpkg-deb (subprocess): subprocess data was killed by signal (Broken pipe)
dpkg-deb: error: subprocess <decompress> returned error exit status 2
Processing triggers for man-db ...
Errors were encountered while processing:
 /var/cache/apt/archives/apache2-bin_2.4.16-4+deb.sury.org~precise+4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

也尝试过这样做,sudo apt-get install php5但得到的基本上是相同的错误。

解决这些依赖问题的正确方法是什么?

答案1

您还必须安装 2.4 版以上的 Apache 服务器。我认为 PPA 不会为您提供此包。因此它打破了依赖关系。然后您将能够安装 php-common 包。

答案2

您可以尝试:

 sudo apt-get update && sudo apt-get install python-software-properties

然后输入以下内容添加:

 sudo add-apt-repository ppa:ondrej/php5-5.6

然后输入以下内容进行更新:

 sudo apt-get update && sudo apt-get dist-upgrade

然后输入以下命令进行安装:

 sudo apt-get install php5

检查PHP版本:

 php --version

仍然收到错误,请尝试:

下载libapache2-mod-php5 http://packages.ubuntu.com/trusty/libapache2-mod-php5

Architecture    Package Size    Installed Size  Files

amd64   2,158.6 kB  9,669.0 kB  [list of files]

i386    2,093.8 kB  9,027.0 kB  [list of files]

输入以下命令安装:

sudo dpkg -i /path/to/deb/file.deb  

sudo apt-get install -f 

享受!

相关内容