I have a few CentOS 5.4 webservers to upgrade from httpd 2.2.3 to 2.2.17, but 2.2.17 isn’t available as an RPM from in any repository that I can find, so I’m making my own. Here’s how I did it.
First, I built a new CentOS 5.4 x64 virtual machine on a spare 64-bit VMware vCenter server using the same ISO as my production machines. This VM will have a plethora of build and development tools that I don’t need or want in production.
Then, I googled around and found some helps on setting up an RPM build environment, including wiki.centos.org, and OwlRiver.com.
Next, I logged in as root, and:
# yum update
# yum groupinstall "Development Tools"
# yum install rpmdevtools rpm-build redhat-rpm-config openssl-devel
Create a user to run the build process, and then become that user:
# /usr/sbin/useradd rpmbuilder
# su - rpmbuilder
Set up rpmbuilder’s environment, using the Owl River’s tips:
$ wget http://www.oldrpm.org/hintskinks/buildtree/RPM-build-tree.txt
$ chmod 755 RPM-build-tree.txt
$ ./RPM-build-tree.txt
Then wget httpd-2.2.17.tar.gz from one of the Apache mirrors, and try a build and see what else is needed. (NOTE: httpd includes an httpd.spec file in the root of the tarball, which greatly simplifies building an RPM from the source — we do not need to create a .spec file to guide the creation of the RPM. If you want to modify the build parameters of the RPM, extract the .spec file (tar zxvf httpd-2.2.17.tar.gz httpd.spec
), modify it, and then specify your .spec file with rpmbuild --rmspec httpd.spec
.)
$ rpmbuild -tb httpd-2.2.17.tar.gz
error: Failed build dependencies:
apr-devel is needed by httpd-2.2.17-1.x86_64
apr-util-devel is needed by httpd-2.2.17-1.x86_64
openldap-devel is needed by httpd-2.2.17-1.x86_64
db4-devel is needed by httpd-2.2.17-1.x86_64
expat-devel is needed by httpd-2.2.17-1.x86_64
pcre-devel >= 5.0 is needed by httpd-2.2.17-1.x86_64
/usr/bin/apr-1-config is needed by httpd-2.2.17-1.x86_64
/usr/bin/apu-1-config is needed by httpd-2.2.17-1.x86_64
When you weren’t looking, I added rpmbuilder to the sudoers file. If you didn’t do that, switch back to root and install the missing packages, but as for me, I sudo-install them as my rpmbuilder
$ sudo /usr/bin/yum install apr-devel apr-util-devel openldap-devel db4-devel expat-devel pcre-devel
And try, try, again:
$ rpmbuild -tb httpd-2.2.17.tar.gz
(Lots of text scrolls past, ending with:
configure: error: distcache support failed: can't include distcache headers
error: Bad exit status from /var/tmp/rpm-tmp.71094 (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.1844 (%build)
Install distcache, then try again.
$ sudo yum install distcache distcache-devel
$ rpmbuild -tb httpd-2.2.17.tar.gz
It builds and builds and builds… it’s working! And you are rewarded with this output:
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.55847
+ umask 022
+ cd /home/rpmbuilder/rpmbuild/BUILD
+ cd httpd-2.2.17
+ rm -rf /var/tmp/httpd-2.2.17-1-root
+ exit 0
Look in the RPMs/arch/ dir for the product of your (or my) hard work:
$ ls rpmbuild/RPMS/x86_64/
httpd-2.2.17-1.x86_64.rpm httpd-devel-2.2.17-1.x86_64.rpm mod_ssl-2.2.17-1.x86_64.rpm
httpd-debuginfo-2.2.17-1.x86_64.rpm httpd-manual-2.2.17-1.x86_64.rpm
Copy httpd-2.2.17-1.x86_64.rpm to a test/dev/QA machine, install it, test your websites, and then repeat in production.
Welcome to 2.2.17!
Dude … that rocked ..
Thnx a lot .. sure save me a shitload of time.
LikeLike
Any option for the same when you use 64bit system and need 32bit rpm ?
LikeLike
For 32-bit, it should work about the same, replacing x86_64 with i386 in each RPM or file name.
Or search http://pkgs.org – I found that site after writing this article. It looks like they have httpd 2.2.17 for i386.
LikeLike
Very slick compile and very usefull.
Many Thanks!
LikeLike
That was a great writeup. I had to install distcache and distcache-devel, as described here. After that, the compile worked like a charm.
LikeLike
Thanks a lot! This article saved my life.
LikeLike