Upgrading Apache httpd on RHEL and CentOS

November 24, 2006 by · 62 Comments 

By popular request, I've decided to write a How-To on upgrading your RHEL or CentOS 4 system from httpd 2.0.52 to 2.2.3. I'm going to issue a warning upfront though, this is NOT a simple src.rpm rebuild like the PHP upgrade how-to that I wrote. Upgrading httpd requires filling a couple dependencies, building httpd, and then rebuilding everything that depends on httpd. For most people, that means just PHP. For some sites, that may include mod_perl, mod_python, etc.

If you're using some kind of management panel like Plesk, CPanel, etc. then DO NOT follow these instructions as you will break your server. In fact, if you have a separate development environment (like an OpenVZ VPS or a separate server) then I'd suggest using that because the build process actually requires you to remove your current copy of httpd. In any case, if you're still interested, keep reading.

To complete this upgrade you're going to need 3 things. First, you'll need 'root' access to your server. Without it, even if you can build the RPMs, you won't be able to install them. Second, you're going to need to install some dependencies to meet the build requirements. Finally, you're going to need to get the src.rpm files for httpd, apr, apr-util, and pcre from FC6.

To start out, if you've never built a src.rpm file before, log in to your server as 'root' and run the following commands:

  • mkdir /usr/src/redhat
  • chmod -R 777 /usr/src/redhat

After that, you'll need to fill some dependencies before you'll be able to build apr, apr-util, pcre, and httpd. To do that, run the OS-appropriate command below as 'root'. If you installed a 'minimal' system then there may be about 80 packages that get pulled in (if you have the 'yum' command, use that, if not, use 'up2date').

  • yum install wget nano diffutils bzip2 python gcc cpp gcc-c++ make autoconf libtool doxygen pkgconfig rpm-build xmlto zlib-devel libselinux-devel openssl-devel distcache-devel e2fsprogs-devel openldap-devel db4-devel expat-devel postgresql-devel sqlite-devel
  • up2date -u wget nano diffutils bzip2 python gcc cpp gcc-c++ make autoconf libtool doxygen pkgconfig rpm-build xmlto zlib-devel libselinux-devel openssl-devel distcache-devel e2fsprogs-devel openldap-devel db4-devel expat-devel postgresql-devel sqlite-devel

Next, switch to a non-root user, download the src.rpms for apr, apr-util, pcre, and httpd to your server, and then type the following:

  • rpm -ivh apr-1.2.7-10.src.rpm
  • rpm -ivh apr-util-1.2.7-3.src.rpm
  • rpm -ivh pcre-6.6-1.1.src.rpm
  • rpm -ivh httpd-2.2.3-5.src.rpm
  • cd /usr/src/redhat/SPECS/

You may see some warnings for each of the 'rpm' commands but there shouldn't be any errors. At this point we can start building the dependencies for httpd. Begin the process by running the following commands:

  • rpm -e httpd httpd-suexec httpd-manual apr-util apr
  • rpmbuild -bb pcre.spec
  • rpm -Uvh ../RPMS/i386/pcre-6.6-1.1.i386.rpm
  • rpm -Uvh ../RPMS/i386/pcre-devel-6.6-1.1.i386.rpm
  • rpmbuild -bb apr.spec
  • rpm -Uvh ../RPMS/i386/apr-1.2.7-10.i386.rpm
  • rpm -Uvh ../RPMS/i386/apr-devel-1.2.7-10.i386.rpm
  • rpmbuild -bb apr-util.spec
  • rpm -Uvh ../RPMS/i386/apr-util-1.2.7-3.i386.rpm
  • rpm -Uvh ../RPMS/i386/apr-util-devel-1.2.7-3.i386.rpm

At this point you've filled all the dependencies and you're ready to start working on httpd. There are four changes you'll want to make. Follow the steps below to make the required change to the init file.

  • nano -w ../SOURCES/httpd.init
  • Press [Ctrl]+[W], then [Ctrl]+[T]
  • Type "74" and press [Enter]
  • Change "killproc -d 10 $httpd" to "killproc $httpd"
  • Press [Ctrl]+[O], [Enter], and then [Ctrl]+[X] to save and then return to the shell.

The next set of changes should be made to the spec file.

  • nano -w httpd.spec
  • Change line #4 from "%define vstring Fedora" to "%define vstring EL"
  • Change line #5 from "%define distro Fedora Core" to "%define distro RHEL-CentOS"
  • Delete line #52.

At this point you can build and install httpd by running:

  • rpmbuild -bb httpd.spec
  • rpm -Uvh ../RPMS/i386/httpd-2.2.3-5.i386.rpm
  • rpm -Uvh ../RPMS/i386/httpd-manual-2.2.3-5.i386.rpm
  • rpm -Uvh ../RPMS/i386/httpd-devel-2.2.3-5.i386.rpm

You'll want to edit the "/etc/httpd/conf/httpd.conf" file to reflect any changes from your old conf file. You'll also need to build PHP, mod_perl, and mod_python if you use them. I did recently write a how-to for upgrading to PHP 5.1.6. If that is the version you'd like to use, feel free to follow my guide.

Digg this story


62 Responses to “Upgrading Apache httpd on RHEL and CentOS”
  1. Steven H. says:

    I'm getting the same error that M Best was getting, but removing the zlib-develi386 isn't solving my problem. It's still saying that the build cannot find the "rules.mk" file, thus turfing out with "bad exit status".

    Not quite sure what to do about this.

  2. Jason says:

    If removing the 32-bit package didn't help then I don't really know what it would be.

    This article is pretty old, you may want to check out the version for 2.2.4 or for my Yum repo so that you can simply install binary packages instead of building from source.

  3. Rad says:

    Sorry but I'm only 3 weeks old linux user , what are the src.rpms for apr, apr-util, pcre, and httpd . and from where can I get them ?
    Or do you mean I have to download the source code then use /.configure then make && make install ?
    Thank you Jason

  4. Jason says:

    src.rpms are source rpm packages. Using the 'rpmbuild' command you can compile the src.rpm into actual RPMs that can be installed on your system. Some packages, such as PHP extensions, can really only be distributed in this manner as they are system-specific (to an extent).

    If this tutorial is beyond you, or you simply don't have the interest in getting that involved, you might be interested in my Yum Repository (see the link at the top of the page); it will allow you to update your system with binary packages and hit everything in one shot.

  5. Brian C. HIll says:

    I'd rather not embark on the 2.0 -> 2.2 upgrade, rather I just want mod_authz_owner. Is the upgrade to 2.2 really the only way to get it? 1.3 had the file-group & file-owner options, but 2.0 only seems to have it with ldap.

    Any suggestions?


  6. Jason says:


    The mod_authz_owner module was introduced in 2.2. If you want to use it then you'll need to upgrade.


  7. Kewal B.K. says:

    I followed the step mentioned above.
    But when I try to install the httpd rpm i get the following dependency error:

    $ rpm -Uvh ../RPMS/i386/httpd-2.2.3-5.i386.rpm
    error: Failed dependencies:
    initscripts >= 8.36 is needed by httpd-2.2.3-5.i386

    I was wondering how to get rid of this problem.

  8. Jason says:


    That is not a problem that I have experienced, you could try changing the dependency in the spec file to not include a version.

    Honestly though, I would suggest that you read some of the newer articles on my site. This one is 10 months old and since then I've posted about 2.2.4 and 2.2.6. Both of those articles include pre-modded src.rpms at the bottom of the posts and binary RPMs are available for both in my yum repository.

  9. Jeremy says:

    Thanks for this! I was having a hell of a time and this was just what I needed.


  10. Baby says:

    Upgare Apache On Cpanel
    hello dears,
    i have a problem with me apache and the site's settings.
    my apache version is very old and i want to upgrade with the
    apache 2.2,but i have a little information to do that
    if there is no problem please tell me how can i upgrade my apache with cpanel manager(explain step by step)
    and my server's operation is linux.
    another question is: when i design a php e-mail sender and i send an e-mail to
    another mail in the diffrent server when i recive that and check it , it was from another server
    but the user be same, for example: my e-mail : [email protected] but i recive [email protected]

  11. Sam says:

    I have a question what happend with https?, my apache 2.2 is working very well, but i cannot install mod_ssl, have you been able to install mod_ssl at http 2.2?

  12. Julia says:

    Hi Jason,

    Thanks for the yum repo. Been using it for a while now.
    Couple of questions:

    1. I see that you haven't made any customizations to the httpd src code. Any reason to build the binary from srpms rather than downloading a binary rpm from some provider (like rpmbone.net for instance) and hosting it on your repo? Also, why not build the binary from actual source thats available at httpd.apache.org/ instead of using SRPMs?

    2. httpd.spec has been modified by you for RHEL, but what about other packages like apr, apr-util, and pcre? Those are Fedora SRPMs too right? If there are any references to "Fedora" in the .spec files of these packages, shouldn't they be changed to "RHEL-Centos" like the way you did for httpd.spec?

    3. One last question, what are the source rpms you've got here: http://www.jasonlitka.com/media/SRPMS/ ?


This site is no longer updated. If you have a need for RHEL/CentOS LAMP Stack updates outside the normal channels, I recommend ART. https://updates.atomicorp.com/channels/