Saturday, July 25, 2015

Building apache httpd RPMs from source on Centos 6

Probably works on RHEL as well. I used a fresh install of Centos 6.6.

# mkdir -p ~/rpmbuild/{SOURCES,SPECS,BUILD,RPMS,SRPMS}
# cd ~rpmbuild/SOURCES

Wget the latest source for httpd and apr, apr-util from your closest mirror:
# wget http://apache.mirrors.pair.com/httpd/httpd-2.4.16.tar.bz2
# wget http://apache.arvixe.com/apr/apr-1.5.2.tar.bz2
# wget http://apache.arvixe.com/apr/apr-util-1.5.4.tar.bz2

Build and install apr:
# rpmbuild -tb apr-1.5.2.tar.bz2
# rpm -ivh ~/rpmbuild/RPMS/x86_64/apr-1.5.2-1.x86_64.rpm \
~/rpmbuild/RPMS/x86_64/apr-devel-1.5.2-1.x86_64.rpm

Build apr-util:
 # rpmbuild -tb apr-util-1.5.4.tar.bz2
error: Failed build dependencies:
        expat-devel is needed by apr-util-1.5.4-1.x86_64
        libuuid-devel is needed by apr-util-1.5.4-1.x86_64
        freetds-devel is needed by apr-util-1.5.4-1.x86_64
        unixODBC-devel is needed by apr-util-1.5.4-1.x86_64

Alrighty then:
# yum -y install expat-devel libuuid-devel freetds-devel unixODBC-devel
freetds is from the epel repo. Be sure to enable that, since it isn't installed by default.

# rpmbuild -tb apr-util-1.5.4.tar.bz2 => OK!
# rpm -ivh ~/rpmbuild/RPMS/x86_64/apr-util-1.5.4-1.x86_64.rpm \
~/rpmbuild/RPMS/x86_64/apr-util-devel-1.5.4-1.x86_64.rpm

Httpd requires distcache for mod_socache_dc. Distcache doesn't have an RPM. If there is no need for  mod_socache_dc, you can try commenting out the following lines in httpd.spec:
%package -n mod_socache_dc
Group: System Environment/Daemons
Summary: Distcache shared object cache module for the Apache HTTP server
BuildRequires: distcache-devel
Requires: httpd = %{version}-%{release}, httpd-mmn = %{mmn}

Otherwise:
1. Use this distcache.spec file and follow instructions. If you go this this route you don't need to use "--nodeps" in the rpmbuild process in the final step.
2. Download distcache-1.5.1.tar.bz2 and build the old way from http://sourceforge.net/projects/distcache/files.
# tar xjf distcache-1.5.1.tar.bz2
# cd distcache-1.5.1
-fPIC fixed a weird httpd build issue for me. May not be needed otherwise.
# ./configure CFLAGS="-fPIC"
# make
Make fails with 'error "LONG_MIN" undeclared' . Fix it by adding:
# include <limits.h>
on line 29 of /distcache-1.5.1/libnal/proto_fd.c
# make
# make install

Now that distcache has been installed (or skipped), we can build httpd:
# rpmbuild -tb httpd-2.4.16.tar.bz2
error: Failed build dependencies:
     pcre-devel is needed by httpd-2.4.16-1.x86_64
     lua-devel is needed by httpd-2.4.16-1.x86_64
     distcache-devel is needed by httpd-2.4.16-1.x86_64
Alrighty then:
# yum -y install pcre-devel lua-devel

If we installed distcache the old school way (compiling without RPMs!) use --nodeps to ignore distcache-devel. If you created an RPM for distcache-devel you wouldn't need --nodeps.
# rpmbuild -tb --nodeps httpd-2.4.16.tar.bz2
# rpm -ivh ~/rpmbuild/RPMS/x86_64/httpd-2.4.16-1.x86_64.rpm \
~/rpmbuild/RPMS/x86_64/httpd-tools-2.4.16-1.x86_64.rpm \
~/rpmbuild/RPMS/x86_64/httpd-devel-2.4.16-1.x86_64.rpm \
~/rpmbuild/RPMS/x86_64/mod_ssl-2.4.16-1.x86_64.rpm

That's it!

Thanks to:
http://www.erikwebb.net/blog/compile-and-install-apache-24-red-hat-enterprise-linux-rhel-6-or-centos-6/

For having me look in the right direction.


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home