![E: 更新 php 时子进程 /usr/bin/dpkg 返回错误代码 (1)](https://linux22.com/image/79712/E%3A%20%E6%9B%B4%E6%96%B0%20php%20%E6%97%B6%E5%AD%90%E8%BF%9B%E7%A8%8B%20%2Fusr%2Fbin%2Fdpkg%20%E8%BF%94%E5%9B%9E%E9%94%99%E8%AF%AF%E4%BB%A3%E7%A0%81%20(1).png)
我尝试将 php 更新到 php5 并出现以下错误。
root@Ansible-VirtualBox:~# apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
libbsd0
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libedit2 libgd3 libvpx1
php5-cli php5-common php5-gd php5-json
Suggested packages:
apache2-doc apache2-suexec-pristine apache2-suexec-custom libgd-tools
php-pear php5-user-cache
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 libgd3 libvpx1 php5-json
The following packages will be upgraded:
apache2 apache2-utils libedit2 php5-cli php5-common php5-gd
6 upgraded, 5 newly installed, 3 to remove and 6 not upgraded.
1 not fully installed or removed.
Need to get 0 B/5,489 kB of archives.
After this operation, 2,659 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 177484 files and directories currently installed.)
Unpacking apache2-bin (from .../apache2-bin_2.4.17-2+deb.sury.org~precise+1_i386.deb) ...
dpkg: error processing /var/cache/apt/archives/apache2-bin_2.4.17-2+deb.sury.org~precise+1_i386.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.17-2+deb.sury.org~precise+1_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
当我尝试删除以前安装的版本和软件包时,出现以下错误。
root@Ansible-VirtualBox:~# apt-get remove apache2
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-common (= 5.5.30+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).
root@Ansible-VirtualBox:~# apt-get remove apache2.2-bin
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:
apache2-mpm-prefork : Depends: apache2.2-bin (= 2.2.22-1ubuntu1.10) but it is not going to be installed
apache2.2-common : Depends: apache2.2-bin (= 2.2.22-1ubuntu1.10) but it is not going to be installed
libapache2-mod-php5 : Depends: apache2-api-20120211
Depends: apache2 (>= 2.4)
Depends: php5-common (= 5.5.30+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).
root@Ansible-VirtualBox:~# apt-get remove apache2-
apache2-mpm-prefork apache2-utils
root@Ansible-VirtualBox:~# apt-get remove apache2
apache2 apache2.2-bin apache2.2-common apache2-mpm-prefork apache2-utils
root@Ansible-VirtualBox:~# apt-get remove apache2.2-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:
apache2 : Depends: apache2.2-common (= 2.2.22-1ubuntu1.10) but it is not going to be installed
apache2-mpm-prefork : Depends: apache2.2-common (= 2.2.22-1ubuntu1.10) but it is not going to be installed
libapache2-mod-php5 : Depends: apache2-api-20120211
Depends: apache2 (>= 2.4)
Depends: php5-common (= 5.5.30+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).
答案1
找到原因了。
dpkg: error processing /var/cache/apt/archives/apache2-bin_2.4.17-2+deb.sury.org-precise+1_i386.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
你显然有三(!!)apache
同时安装的版本(或“仅”两个,并且您尝试添加第三个):v2.2.22、v2.4.17 和 v2.8。根本不建议这样做,甚至容易出现错误或服务器故障!
你应该严格遵守一你的三个版本中apache
有和卸载所有剩余的 apache 版本(即 Ubuntu Precise Pangolin 的 2.2.22 版本和 2.4.17):
$ sudo apt-get remove <name of previous package(s)>
(尝试输入apa
然后使用Tabkey选择正确的包名)
你的系统似乎因这些奇怪的版本混乱而混乱不堪apache
。