apt-get无法升级软件包。

我正在运行Ubuntu 12.04服务器。
user@host:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:        12.04
Codename:       precise

我的问题是这样的:当我想要升级软件包(特别是寻找php5,但也会发生在许多/大部分/全部)时,我得到的结果如下:
user@host:~$ sudo apt-get upgrade
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-suexec-custom : Depends: apache2-bin but it is not installed
E: Unmet dependencies. Try using -f.


user@host:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libnet-xwhois-perl libtommath0
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  apache2-bin
The following NEW packages will be installed:
  apache2-bin
0 upgraded, 1 newly installed, 0 to remove and 29 not upgraded.
1 not fully installed or removed.
Need to get 0 B/953 kB of archives.
After this operation, 3576 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 95668 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)

我该怎么解决这些错误?我真的很想使用比5.3更新的PHP版本,因为我有多个项目需要至少PHP v5.4。
注意:我不是在尝试修复区域设置问题,我是在尝试修复dpkg错误。这台服务器一直存在区域设置问题,而且完全是另一个问题。抱歉,但这不是重复的问题。
附加代码的编辑:
user@host:~$ sudo dpkg --configure -a
dpkg: dependency problems prevent configuration of apache2-suexec-custom:
 apache2-suexec-custom depends on apache2-bin; however:
  Package apache2-bin is not installed.
dpkg: error processing apache2-suexec-custom (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 apache2-suexec-custom

执行sudo apt-get install apache2的输出结果为:
user@host:~$ sudo apt-get install 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:
 apache2 : Depends: apache2-bin (= 2.4.16-4+deb.sury.org~precise+4) but it is not going to be installed
           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
 apache2-suexec-custom : Depends: apache2-bin but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).






好的,这是我刚刚发现的情况。删除了apache2-suexec-custom后,一切似乎正常工作。但我仍然遇到同样的问题:
user@host:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have been kept back:
  apache2 libapache2-mod-php5 libjson0:i386 php-apc php-pear php5 php5-cgi php5-cli php5-common php5-curl php5-dev php5-fpm php5-gd php5-imagick php5-imap php5-intl
  php5-ldap php5-mcrypt php5-memcache php5-ming php5-mysql php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.

user@host:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.

那么这29个没有升级的是怎么回事?我打算先四处浏览,看看其他问题中是否可以找到答案...
太棒了!看看DanielSmith-Chatbot的答案就能解决我的问题...

2可能是如何解决我的区域设置问题?的重复问题。 - Charles Green
向下滚动@CharlesGreen和点赞者。这个服务器一直有这个问题,但一切都还好。我正在尝试修复dpkg错误。 - Daniel
这与你的情况并不完全相关,但是这个答案中的回答可能有助于解决问题。 - Charles Green
See edits to question. - Daniel
我在这里被难住了。 - Daniel
嗯,如果是我的话...我会备份所有相关文件,然后基本上重新开始。我看到了一些帖子,基本上是先移除apache2,然后再重新安装它。 - Charles Green
sudo apt-get install apache2-bin 的输出是什么?你能把它添加到你的帖子中吗? - Neil
抱歉,我无法访问链接中的文本内容。请提供您需要翻译的具体文本,我将尽力为您提供准确的翻译。谢谢! - Daniel
@Daniel - 你之前安装过apache和apache2吗?因为由于软件包冲突,只能选择一个软件包。接下来的问题是:你使用以下命令sudo apt-get install --reinstall apache2 --fix-missing有什么输出结果? - dschinn1001
我已经安装了apache和apache2,但是当我运行sudo apt-get upgrade时,我注意到了这个问题。 - Daniel
3个回答

好的,这是问题所在:

有一个名为apache2-suexec-custom的软件包出现了严重的混乱,它需要并且讨厌同一个软件包。删除它,其他软件包就可以进行dist-upgrade了。运行sudo apt-get dist-upgrade ; sudo apt-get upgrade,一切都会升级。

谢谢你们的帮助!虽然不是预期的解决方案,但它起作用了!


1我很高兴能为您提供服务。 - Daniel Smith - Chatbot


不行,它给我一个未满足的依赖项。 - Daniel
@Daniel - 请检查一下apache2是否依赖于类似libc或glibc这样的库?!- 等一下,我来查一下...请稍等片刻。 - dschinn1001
嗯,sudo apt-get install libc* 仍然出现未满足的依赖项。我开始觉得我的软件源(或其中一个软件源)可能已经损坏。 - Daniel
好的,看一下这个错误:http://www.km4ayu.com/errors/error4.txt - Daniel
看起来apache2-bin既是一个依赖包,又是一个冲突包。 - Daniel


如果你尝试修复本地设置但没有成功,请移除sudo apt-get remove --purge apache2-suexec-custom并重新安装它。 - Phan Văn Vũ
这个链接可能是一个答案,但你的帖子不是。 - user284234
我尝试过了,但它并没有解决这个问题。 - Daniel
但是它确实解决了区域设置问题。但这是一个无关紧要的答案。 - Daniel