Build Apache HTTP server 2.4.x RPM package on CentOS 6

Nicol Leung
2 min readMar 6, 2018

Install rpmbuild

yum install rpm-build

Download the tarball from official website. bz2 format is needed for building RPM from tarball as the bundled spec file uses bz2 file format. We can build the RPM directly from the tarball, but we need to change the httpd.spec file, so extract the tarball first. Edit httpd.spec as follows:

Under %configure add these lines (extracted from CentOS httpd rpm)

--prefix=%{_sysconfdir}/httpd \
--exec-prefix=%{_prefix} \
--bindir=%{_bindir} \
--sbindir=%{_sbindir} \
--mandir=%{_mandir} \
# Also enable other useful functions
--enable-so \
--enable-info \
--enable-rewrite \

Copy httpd-2.4.29.tar.bz2 to /root/rpmbuild/SOURCES/ , then run

rpmbuild -bb httpd.spec

You may get error message saying prerequisites are missing, copy the package name on error message and install them via yum, but apr-devel , apr-util-devel and distcache-devel package should not be installed via yum. Here is an example of what is needed.

yum install autoconf libuuid-devel lua-devel libxml2-devel

Download apr and apr-util from official website. bz2 format is needed for building RPM from tarball as the bundled spec file uses bz2 file format. Run rpmbuild and install any prerequisites needed by rpmbuild again.

rpmbuild -tb apr-1.6.3.tar.bz2
rpmbuild -tb apr-util-1.6.1.tar.bz2

Then install the RPMs

rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-1.6.3-1.x86_64.rpm
rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-devel-1.6.3-1.x86_64.rpm
rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-util-1.6.1-1.x86_64.rpm
rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-util-devel-1.6.1-1.x86_64.rpm

Download distcache and distcache-devel from http://rpm.pbone.net and install them.

rpm -Uvh distcache-1.4.5-23.x86_64.rpm
rpm -Uvh distcache-devel-1.4.5-23.x86_64.rpm

Now all prerequisites are installed and we can build the RPM

rpmbuild -bb httpd.spec

Lastly you should have the RPM for installation

yum install /root/rpmbuild/RPMS/x86_64/apr-1.6.3-1.x86_64.rpm
yum install /root/rpmbuild/RPMS/x86_64/apr-util-1.6.1-1.x86_64.rpm
yum install /root/rpmbuild/RPMS/x86_64/httpd-2.4.29–1.x86_64.rpm

Other Apache components can be installed as Apache modules. Follow ups will be provided in other articles for building these components.

--

--