Upgrading Apache httpd on RHEL and CentOS
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