Why does `rpm` show 3 httpd packages, and which one provides the real httpd?

Stefan Lasiewski asked:

I ran yum update on my CentOS5 webserver a few days ago. Today I just noticed that I have 3 httpd-* rpms!

How can I end up with three RPMs for httpd (My other servers only have one httpd rpm). I want to make sure that my server has a patched, updated version of /usr/sbin/httpd. How can I tell which one of these packages provides the httpd binary at /usr/sbin/httpd?

[[email protected] ~]# rpm -q httpd
httpd-2.2.3-76.el5.centos
httpd-2.2.3-78.el5.centos
httpd-2.2.3-83.el5.centos

[[email protected] ~]# /usr/sbin/httpd -V |grep version
Server version: Apache/2.2.3

[[email protected] ~]# rpm -q httpd-2.2.3-76.el5.centos --list |grep -w /usr/sbin/httpd
/usr/sbin/httpd
/usr/sbin/httpd.event
/usr/sbin/httpd.worker
[[email protected] ~]# rpm -q httpd-2.2.3-78.el5.centos --list |grep -w /usr/sbin/httpd
/usr/sbin/httpd
/usr/sbin/httpd.event
/usr/sbin/httpd.worker
[[email protected] ~]# rpm -q httpd-2.2.3-83.el5.centos --list |grep -w /usr/sbin/httpd
/usr/sbin/httpd
/usr/sbin/httpd.event
/usr/sbin/httpd.worker
[[email protected] ~]# 

[email protected] ~]# rpm -q --provides httpd |grep -w httpd
config(httpd) = 2.2.3-76.el5.centos
httpd-mmn = 20051115
httpd = 2.2.3-76.el5.centos
config(httpd) = 2.2.3-78.el5.centos
httpd-mmn = 20051115
httpd = 2.2.3-78.el5.centos
config(httpd) = 2.2.3-83.el5.centos
httpd-mmn = 20051115
httpd = 2.2.3-83.el5.centos

Update: Answering Mark Wagner’s questions:

[[email protected] ~]# rpm -q -f /usr/sbin/httpd 
httpd-2.2.3-76.el5.centos
httpd-2.2.3-78.el5.centos
httpd-2.2.3-83.el5.centos
[[email protected] ~]# rpm -V httpd-2.2.3-83.el5.centos
S.5.....  c /etc/logrotate.d/httpd
S.5.....  c /etc/rc.d/init.d/httpd
....L...    /var/www

Update2: Attempting to rebuild the RPM database, with no luck

[[email protected] ~]# cd /var/lib
[[email protected] lib]# tar zcvf /var/preserve/rpmdb-`date +"%d%m%Y"`.tar.gz rpm
[[email protected] lib]# cd /var/lib/rpm
[[email protected] rpm]# rm -f __db*
[[email protected] rpm]# /usr/lib/rpm/rpmdb_verify Packages
[[email protected] rpm]# mv Packages Packages.orig
[[email protected] rpm]# /usr/lib/rpm/rpmdb_dump Packages.orig | /usr/lib/rpm/rpmdb_load P
ackages
[[email protected] rpm]# /usr/lib/rpm/rpmdb_verify Packages
[[email protected] rpm]# rpm -qa 1> /dev/null
[[email protected] rpm]# rpm -v --rebuilddb
[[email protected] rpm]# rpm -q httpd
httpd-2.2.3-76.el5.centos
httpd-2.2.3-78.el5.centos
httpd-2.2.3-83.el5.centos
[[email protected] rpm]# 

My answer:


This looks like a classic case of interrupted updates. An update is done in two stages: the new files are installed and the new packages added to the database, then any old files are removed and the old package removed from the database. If the update is interrupted between these two steps, you get this sort of inconsistency.

What I would do with this situation is (this will require a brief maintenance window):

  1. Save a copy of your configuration files. RPM will do this anyway with an .rpmsave extension for any files you modified, but it’s best to be doubly sure.

  2. Forcibly remove all of the packages:

    rpm -e --allmatches httpd
    
  3. Reinstall the package:

    yum -y install httpd
    
  4. Restore your configuration files.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.