I previously mentioned rpmbuild. I wanted to write a little post on what it does and how useful it is. But I though it would be easier to just show you.

So what is rpmbuild? It is a tool for building rpm packages based on a spec file. The resulting rpm should be close to the rpm provided by your distribution. I’ve used rpmbuild on both Fedora and CentOS to create Apache HTTPd 2.4 binaries that works as a drop in replacement for the system ones.

So how does it work? I’ll just show you!

You need to install rpmbuild first. (You should also install the development tools.)

yum install rpm-build
useradd -m -c "rpmbuild user" rpmbuild

Download the apr, apr-util and httpd source code from apache.org.
Then simply run rpmbuild against the tar archive. (You need to start with apr, apr-util and work your way to httpd.)

sudo su - rpmbuild
rpmbuild -ta httpd-2.4.2.tar.bz2
sudo rpm -Uvh rpmbuild/RPMS/x86_64/httpd-2.4.2-1.x86_64.rpm

This is far from a step by step, but it should give you a general idea what rpmbuild does and how it can be used for building binaries on CentOS or another rpm based distribution.

Rpmbuild will point out which packages you are missing, just install them and you should be fine.
You may also experience an error on the new apr-util, if you do get the patch posted here.