首页 > 解决方案 > 无法在 debian 上安装 libapache2-mod-php5

问题描述

当我尝试在 debian(Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.41-2 i686 GNU/Linux)上安装 libapache2-mod-php5 时,我得到以下输出:

root@debian:~# apt-get install libapache2-mod-php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apache2-bin apache2-data
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  apache2-mpm-prefork apache2.2-bin apache2.2-common
Suggested packages:
  apache2-doc apache2-suexec apache2-suexec-custom
The following packages will be REMOVED:
  apache2
The following NEW packages will be installed:
  apache2-mpm-prefork apache2.2-bin apache2.2-common libapache2-mod-php5
0 upgraded, 4 newly installed, 1 to remove and 274 not upgraded.
Need to get 0 B/3,728 kB of archives.
After this operation, 12.3 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 72217 files and directories currently installed.)
Removing apache2 (2.4.25-3+deb9u3) ...
[ ok ] Stopping Apache htcacheclean: apache-htcacheclean.
[ ok ] Stopping Apache httpd web server: apache2.
Processing triggers for man-db (2.7.6.1-2) ...
(Reading database ... 72168 files and directories currently installed.)
Preparing to unpack .../apache2.2-bin_2.2.22-13+deb7u12_i386.deb ...
Unpacking apache2.2-bin (2.2.22-13+deb7u12) ...
dpkg: error processing archive /var/cache/apt/archives/apache2.2-bin_2.2.22-13+deb7u12_i386.deb (--unpack):
 trying to overwrite '/usr/lib/apache2/modules/mod_rewrite.so', which is also in package apache2-bin 2.4.25-3+deb9u3
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../apache2.2-common_2.2.22-13+deb7u12_i386.deb ...
Unpacking apache2.2-common (2.2.22-13+deb7u12) ...
dpkg: error processing archive /var/cache/apt/archives/apache2.2-common_2.2.22-13+deb7u12_i386.deb (--unpack):
 trying to overwrite '/usr/share/man/man8/apache2.8.gz', which is also in package apache2-bin 2.4.25-3+deb9u3
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../apache2-mpm-prefork_2.2.22-13+deb7u12_i386.deb ...
Unpacking apache2-mpm-prefork (2.2.22-13+deb7u12) ...
dpkg: error processing archive /var/cache/apt/archives/apache2-mpm-prefork_2.2.22-13+deb7u12_i386.deb (--unpack):
 trying to overwrite '/usr/sbin/apache2', which is also in package apache2-bin 2.4.25-3+deb9u3
Selecting previously unselected package libapache2-mod-php5.
Preparing to unpack .../libapache2-mod-php5_5.4.45-0+deb7u14_i386.deb ...
Unpacking libapache2-mod-php5 (5.4.45-0+deb7u14) ...
Processing triggers for man-db (2.7.6.1-2) ...
Errors were encountered while processing:
 /var/cache/apt/archives/apache2.2-bin_2.2.22-13+deb7u12_i386.deb
 /var/cache/apt/archives/apache2.2-common_2.2.22-13+deb7u12_i386.deb
 /var/cache/apt/archives/apache2-mpm-prefork_2.2.22-13+deb7u12_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@debian:~# sudo apt-get purge apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'apache2-mpm-prefork' is not installed, so not removed
Package 'apache2.2-bin' is not installed, so not removed
Package 'apache2.2-common' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  apache2* apache2-utils* libapache2-mod-php5*
0 upgraded, 0 newly installed, 3 to remove and 274 not upgraded.
1 not fully installed or removed.
After this operation, 9,097 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 72174 files and directories currently installed.)
Removing libapache2-mod-php5 (5.4.45-0+deb7u14) ...
Purging configuration files for libapache2-mod-php5 (5.4.45-0+deb7u14) ...
Purging configuration files for apache2 (2.4.25-3+deb9u3) ...
dpkg: warning: while removing apache2, directory '/var/www' not empty so not removed
Removing apache2-utils (2.4.25-3+deb9u3) ...
Processing triggers for man-db (2.7.6.1-2) ...
root@debian:~# apt-get install libapache2-mod-php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apache2-bin apache2-data
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common
Suggested packages:
  apache2-doc apache2-suexec apache2-suexec-custom
The following NEW packages will be installed:
  apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5
0 upgraded, 5 newly installed, 0 to remove and 274 not upgraded.
Need to get 0 B/3,950 kB of archives.
After this operation, 13.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 71981 files and directories currently installed.)
Preparing to unpack .../apache2.2-bin_2.2.22-13+deb7u12_i386.deb ...
Unpacking apache2.2-bin (2.2.22-13+deb7u12) ...
dpkg: error processing archive /var/cache/apt/archives/apache2.2-bin_2.2.22-13+deb7u12_i386.deb (--unpack):
 trying to overwrite '/usr/lib/apache2/modules/mod_rewrite.so', which is also in package apache2-bin 2.4.25-3+deb9u3
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Selecting previously unselected package apache2-utils.
Preparing to unpack .../apache2-utils_2.4.25-3+deb9u3_i386.deb ...
Unpacking apache2-utils (2.4.25-3+deb9u3) ...
Preparing to unpack .../apache2.2-common_2.2.22-13+deb7u12_i386.deb ...
Unpacking apache2.2-common (2.2.22-13+deb7u12) ...
dpkg: error processing archive /var/cache/apt/archives/apache2.2-common_2.2.22-13+deb7u12_i386.deb (--unpack):
 trying to overwrite '/usr/share/man/man8/apache2.8.gz', which is also in package apache2-bin 2.4.25-3+deb9u3
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../apache2-mpm-prefork_2.2.22-13+deb7u12_i386.deb ...
Unpacking apache2-mpm-prefork (2.2.22-13+deb7u12) ...
dpkg: error processing archive /var/cache/apt/archives/apache2-mpm-prefork_2.2.22-13+deb7u12_i386.deb (--unpack):
 trying to overwrite '/usr/sbin/apache2', which is also in package apache2-bin 2.4.25-3+deb9u3
Selecting previously unselected package libapache2-mod-php5.
Preparing to unpack .../libapache2-mod-php5_5.4.45-0+deb7u14_i386.deb ...
Unpacking libapache2-mod-php5 (5.4.45-0+deb7u14) ...
Processing triggers for man-db (2.7.6.1-2) ...
Errors were encountered while processing:
 /var/cache/apt/archives/apache2.2-bin_2.2.22-13+deb7u12_i386.deb
 /var/cache/apt/archives/apache2.2-common_2.2.22-13+deb7u12_i386.deb
 /var/cache/apt/archives/apache2-mpm-prefork_2.2.22-13+deb7u12_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

那就是我之前是否安装了apache2。

有任何想法吗?提前致谢!

标签: linuxdebianmod-php

解决方案


您应该首先调用apt-get autoremoveapt 工具告诉您

The following packages were automatically installed and are no longer required:
  apache2-bin apache2-data
Use 'apt-get autoremove' to remove them.

由于您的问题似乎来自不同 apache 版本的文件之间的冲突,更具体地说,来自不再使用的旧安装...

dpkg: error processing archive /var/cache/apt/archives/apache2.2-bin_2.2.22-13+deb7u12_i386.deb (--unpack):
 trying to overwrite '/usr/lib/apache2/modules/mod_rewrite.so', which is also in package apache2-bin 2.4.25-3+deb9u3

推荐阅读