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?

[root@node1 ~]# rpm -q httpd
httpd-2.2.3-76.el5.centos
httpd-2.2.3-78.el5.centos
httpd-2.2.3-83.el5.centos

[root@node1 ~]# /usr/sbin/httpd -V |grep version
Server version: Apache/2.2.3

[root@node1 ~]# 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
[root@node1 ~]# 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
[root@node1 ~]# 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
[root@node1 ~]# 

root@node1 ~]# 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:

[root@node1 ~]# 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
[root@node1 ~]# 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

[root@node1 ~]# cd /var/lib
[root@node1 lib]# tar zcvf /var/preserve/rpmdb-`date +"%d%m%Y"`.tar.gz rpm
[root@node1 lib]# cd /var/lib/rpm
[root@node1 rpm]# rm -f __db*
[root@node1 rpm]# /usr/lib/rpm/rpmdb_verify Packages
[root@node1 rpm]# mv Packages Packages.orig
[root@node1 rpm]# /usr/lib/rpm/rpmdb_dump Packages.orig | /usr/lib/rpm/rpmdb_load P
ackages
[root@node1 rpm]# /usr/lib/rpm/rpmdb_verify Packages
[root@node1 rpm]# rpm -qa 1> /dev/null
[root@node1 rpm]# rpm -v --rebuilddb
[root@node1 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
[root@node1 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 answer on Server Fault.

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