Upgrading Apache httpd on RHEL and CentOS
November 24, 2006 by Jason · 62 Comments
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
Thanks for how-to. I was stuck for httpd and php upgrade before I've found you blog.
I've got this error when try to remove httpd
[[email protected] SPECS]# rpm -e httpd httpd-suexec httpd-manual apr-util apr
error: package httpd-manual is not installed
[[email protected] SPECS]# rpm -e httpd httpd-suexec apr-util apr
error: Failed dependencies:
httpd-mmn = 20020903 is needed by (installed) php-5.1.6-3.1.i386
apr-util = 0.9.4-21 is needed by (installed) apr-util-devel-0.9.4-21.i386
apr = 0.9.4-24.5.c4.2 is needed by (installed) apr-devel-0.9.4-24.5.c4.2.i386
i've try to remove them with --nodeps command.
and other thing need to remove is old pcre if not we can't install pcre
i used
#yum remove pcre
now i'm on step rpmbuild -bb apr.spec
I've bad luck now i stuck at rpmbuild apr.spec
FAILED 1 of 4
testvsn : SUCCESS
Failed Tests Total Fail Failed %
===================================================
testuser 4 1 25.00%
+ exit 1
error: Bad exit status from /var/tmp/rpm-tmp.76066 (%check)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.76066 (%check)
Oops... You'll also need to remove php-*, mod_perl, and mod_python if you have them installed.
As to the last error, did you run "rpmbuild -bb apr.spec" or "rpmbuild apr.spec"?
Also, are you using RHEL4 or CentOS4? What is the exact OS version ('cat /etc/redhat-release')?
Finally, is this an x86 or an x86-64 install? I've only tested this on an x86 install as I do not have a spare x86-64 box I can use.
i use CentOS4 on x86
now my apache is down since uninstall T T
I've just upgrade php from your how to if i uninstall them i need to build it again?
please advise me
If you are going to upgrade httpd then you would need to build php AFTER httpd is done and installed.
For mod_ssl, you can install the new mod_ssl that is built with these steps if you edit the httpd.spec file and change the dependency for openssl to >= 0.9.7a. If you don't you will get an RPM dependency error when trying to install it (wants openssl >= 0.9.7f). Even with this change, you will still get a script failure looking for localhost.crt on the install because Fedora moved all the cert stuff around compared to RHEL4, but it does install it.
Before you do anything on the real server that you want to install the httpd 2.2 rpm's on, you must backup all of /etc/httpd/conf (ssl.* stuff) and /etc/httpd/conf.d/ssl.conf from your real server before removing the apache 2.0 rpm's, then replace those files after installing the new RPM's.
With that, mod_ssl seems to be working ok (for me)!
Hi All
I am running LAMP on x86 system.
The current versions of apps are as follows
RHEL 4
Apache: 2.0.52-19
MySql: 4.1.12-3
PHP: 5.0.4-5
I would like to upgrade all these apps with following versions
Apache: 2.2.3
MySql: 5.0
PHP: 5.2
I was wondering, if I uninstall all these packages and install fresh with the latest versions I have. Is it sensible to follow this procedure?
If you are looking to upgrade to httpd 2.2.3, mysql 5.0.27, and php 5.2.0 then yes, the easiest way would probably be to follow my tutorials. The correct build order would be mysql, httpd, and then php.
httpd 2.2.3, mysql 5.0.27, and php 5.2.0 rpms on RHEL4
Thanks Jason
The bottomline is to minimize the downtime
let me go through this motion once and get back to you
If you are looking to minimize downtime then you might want to wait a day or two until I post up an article on virtualization with OpenVZ. That's what I use to provide a clean build environment when I create these RPMs or want to test something.
I'am trying to upgrade a stripped down Centos 4.4 system. It
does not have any web server software on the system. I have
been following your upgrade instructions which have worked
well. I up to the point where you run the "rpmbuild -bb apr.spec"
command and I get the following error: configure: error: C preprocessor
"/lib/cpp/" fails sanity check. What could be going wrong?
Thanks In advance for any help that you can give me.....
Frank Ford
Do you have the 'cpp' package installed? It should have been added through that large list of deps up at the top of the tutorial. Try running 'rpm -q cpp' and seeing if it tells that it is installed. If not, install it. If so, please upload your 'config.log' file (should be somewhere under '/usr/src/redhat/BUILD/httpd-2.2.3') and post a link so I can take a look at it.
Hi Jason,
Thanks for the article, I had no hassles at all as your article is plain, simple and basic. Thanks again & keep it up! 🙂
Derek Pienaar.
I'm glad to hear that it worked out for you.
Hi Jason,
Thanks for the excellent how-to's! I ran into a problem tho, wondered if you could shed some light on this for me?
I'm upgrading LAMP to 5.0 , I followed the MySQL How-To you wrote and that went very well. Now I am doing httpd 2.2.3 and came across the below problems.
During the rpm removals I had php-* throw me an error, also mailman was a dependancy so I did 'rpm -e httpd httpd-suexec apr-util apr mod_perl mod_ssl mailman' and was ok. Then I ran 'yum remove php' to take care of the php-*.
All was good until I hit the apr build 'rpmbuild -bb apr.spec', now I get:
testatomic : Line 255: Failed creating threads/
/var/tmp/rpm-tmp.37902: line 28: 21908 Segmentation fault ./testall -v -q
exit 1e
error: Bad exit status from /var/tmp/rpm-tmp.37902 (%check)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.37902 (%check)
I don't have a clue as to what I did wrong here...running Centos4.4_x86 on a hosted VPS. What I tried was to reset the VPS and followed the Mysql 5 how to again though this time I used the already built rpm's...which worked fine.
Would you have any ideas on what I did wrong here? Thanks again for the how-to's
If you run 'cat /proc/user_beancounters' do you see any entries that DON'T show zero in the 'failcnt' column?
I've also had an error while rpmbuild -bb apr.spec.
However I can solve this problem by rebuilding directly to the apr:
rpmbuild --rebuild apr-1.2.7-10.src.rpm
thanks for your nice howto!
[quote comment="241"]I've also had an error while rpmbuild -bb apr.spec.
However I can solve this problem by rebuilding directly to the apr:
rpmbuild --rebuild apr-1.2.7-10.src.rpm
thanks for your nice howto![/quote]
I'm not sure why that would make a difference, but I'm glad to hear that you found a way around it. Let me ask you though, were you building as 'root' or a non-root user when it failed? How about when you directly rebuilt the src.rpm?
Both of rpmbuilds were using root. I'm agreed with you that shouldn't make any difference - but something that i can't explain too 😀 By the way, i tried rpmbuild -bb again and its work!
When I try to install dependencies I have a error -
postgresql-libs = 7.4.13-2.RHEL4.1 is needed by package postgresql-devel
but, when try yum upgrade didn't find any package to update , the same messages even try to update postresql-libs
Do you have "postgresql-libs" installed? Run 'rpm -q postgresql-libs' and see if it tells you that it is installed (and what version you have).
Strange, but the response is:
postgresql-libs-8.1.4-1.centos.1
PS thank you very much
That sounds like you've been installing packages out of the 'centosplus' repo. Make sure that you've got 'postgresql', 'postgresql-devel', and 'postgresql-libs' installed, all from the 'centosplus' repo, and you should be OK.
that it is right. Work's now and I have another one
warning: group brewbuilder does not exist - using root
when I try build dependencies. It's killing me. Can I ignore this and use rpmbuild?
Regards
After I reading all your very good tutorials I found the solutions. All information are there and I finish to upgrade it. Help me with mod_auth_* rebuilding please
Very gracefully for all.
By my count there are 14 modules that are built that start with "mod_auth". If one of the ones you need is not on that list you then it may have been removed from httpd or it may not be one that is built by default (in which case you could edit the spec file to enable it and then rebuild).
If the module you want is a 3rd party plugin then you would need to install the httpd-devel package and then consult the documentation from the plugin developer.
When I install the first RPM I get an dependancy error I do not know what to do with:
# rpm -Uvh ../RPMS/i386/pcre-6.6-1.1.i386.rpm
error: failed dependancies: pcre = 6.6-1.1 is needed by pcre-6.6-1.1.i386
I installed CentOS 4 with most of the provided extras and removed the old httpd with the line:
#rpm -e --nodeps httpd httpd-suexec httpd-manual apr-util apr
since here also a dependancy error was given. Can you think of something that is wrong?
Best regards, Sietse.
Do you have an older version of pcre or pcre-devel installed? If so, try removing that first.
Perhaps I should add that pcre-4.5-3.2.RHEL4 and pcre-devel-4.5-3.2.RHEL4 are installed on my system, as I have checked with the command
#rpm -aq | grep pcre
Sietse
Indeed that did the job, although I had to force it again by including --nodeps, but I guess that's alright. Thanks a lot!
S.
Yet some other questions:
I have installed MySQL 5.0.27, httpd 2.3 and PHP 5.1.6 according to your instructions but still encounter some problems:
When I try to start the service httpd I get the message that the auth_kerb_module is garbled. Doe this mean I have to reinstall some programs? Are there more of such dependancies that might be messed up by reinstalling httpd?
When I try to start the service mysql the system tries to but fails without any error message.
Do I have to install seperate server add-ons for MySQL or PHP if I would like to use the system as a LAMP server?
Thanks a lot in advance.
"auth_kerb_module" is not a part of the package that will be built if you followed my instructions. If this is something you had installed from a prior version of httpd then it would need to be recompiled before it will work. That said, unless you're actually using it, just remove it.
As to mysqld failing to start (you are typing "mysqld" and not "mysql", right?), have you checked /var/log/messages and /var/log/mysqld.log (if it exists)?
Hi Jason,
When you say "download the src.rpms for apr, apr-util, pcre, and httpd to your server", where can I get those files from?
I have seen you have some links on this article (http://www.jasonlitka.com/2007/01/17/upgrading-to-httpd-224-on-rhel-centos-4/), but I can't find the links for apr-1.2.7-10.src.rpm, for example.
I was looking at apache.org, but they don't have any rmp's, plus they have the new apr 1.2.8.
I'm stuck running this upgrade for httpd. Is there any way I can contact you by mail or similar?
Thanks in advanced.
All of the files needed for this tutorial can be found in the Fedora Core 6 repo. There are hundreds of mirrors for those files available at http://www.fedoraproject.org.
Hi Jason,
I upgraded my CentOS 4 system to MySQL 5.0.27, PHP 5.1.6 and httpd 2.2.3 (see previous posts) but now I seem to have a problem. I need to reinstall mod_ssl but this module has an ever extending tree of dependancies. I tried your upgrade to httpd 2.2.4 so I could use the mod_ssl on your page, but since I initially used the 2.2.3 source rpm of a different site this apparently does not work. I am considering already either downgrading to httpd 2.0.53 or re-installing the complete system, which would cost me an awfull amount of time. Do you have any suggestions? Many thanks in advance.
Best regards, Sietse
You can't pair the mod_ssl package from httpd 2.2.4 with an install of 2.2.3, it's not going to work correctly.
Where exactly did you get this other httpd 2.2.3 package? In any case, you might simply try removing httpd completely and then starting from scratch with my binaries. Aside from newer apr, apr-util, and pcre libraries, there are no deps to be filled.
I'm running into this problem while trying to build apr-util, Centos 4.4 everything installed up to the rpmbuild -bb apr-util.spec
Makefile:28: /usr/src/redhat/BUILD/apr-util-1.2.7/build/rules.mk: No such file or directory
make: *** No rule to make target `/usr/src/redhat/BUILD/apr-util-1.2.7/build/rules.mk'. Stop.
error: Bad exit status from /var/tmp/rpm-tmp.56123 (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.56123 (%install)
found my problem, I had zlib-devel.i386 installed which was breaking the build process
mbest,
Was that a 64-bit system? If not, there shouldn't have been a problem with having that package installed.
As to building apr, have you considered adding my yum repository to your system? It should make updating your system significantly easier (I'm providing both 32-bit & 64-bit binaries).
My apologies. It may simply be that I'm too linux-dumb to do this right. I took PDFs of your tutorials about a month and a half ago, and finally got the time to try to upgrade the CentOS 4.4 box that is our main webserver. Your httpd2.2.3 tutorial tells us to specifically move to a non-root user. It does not then specify when to go back, as required to run the rpm -Uvh commands.
I was able to update/upgrade both PCRE rpms without error. But when I moved on to the apr* RPMs, I got failed dependencies (libapr-0.so.0 is needed by apr-util-0.9.4.21.i386, mod-Perl-1.99_16-4.centos4.i386, subversion-1.1.4-2.ent.i386, httpd-2.0.52-28.ent.centos4.i386.
I've re-read twice, and I can't see where in this process we're supposed to remove the existing packages, or the commands to be used to do so.
If you do not have a separate development environment where you can build all of the RPMs first and then install all at once, you'll either need to remove the old versions of apr, apr-util, httpd, etc. before installing, otherwise you'll run into the issues you mentioned.
Your best bet would be to configure my yum repository on your system so that you can just run a single command to update your system.
If you could give me the address for that, I'd be happy to do so - ecstatic, really. I think I can find the command I need to set it, given the address, from my O'Rielly book. Thank you, Jason. That is must kind of you.
Whoops. Sorry about that. I found the new article and the link for that. I did the configuration as instructed, and ran 'yum update'. I got the following. I'm not exactly sure where to go from here. Is there any chance you could help advise me?
--> Processing Dependency: libapr-0.so.0 for package: subversion
--> Processing Dependency: httpd-mmn = 20020903 for package: mod_auth_kerb
--> Processing Dependency: httpd-mmn = 20020903 for package: mod_authz_ldap
--> Processing Dependency: httpd-mmn = 20020903 for package: mod_auth_mysql
--> Processing Dependency: libaprutil-0.so.0 for package: subversion
--> Processing Dependency: httpd-mmn = 20020903 for package: mod_auth_pgsql
--> Finished Dependency Resolution
Error: Missing Dependency: httpd-mmn = 20020903 is needed by package mod_auth_kerb
Error: Missing Dependency: libaprutil-0.so.0 is needed by package subversion
Error: Missing Dependency: libapr-0.so.0 is needed by package subversion
Error: Missing Dependency: httpd-mmn = 20020903 is needed by package mod_authz_ldap
Error: Missing Dependency: httpd-mmn = 20020903 is needed by package mod_auth_mysql
Error: Missing Dependency: httpd-mmn = 20020903 is needed by package mod_auth_pgsql
Hi. Me again. I wanted to document this for anyone else who finds yuor site and has similar challenges. I did the following:
# rpm -qa | grep subversion
subversion-1.1.4-2.ent
# rpm -e subversion-1.1.4-2.ent
# rpm -qa | grep mod_auth_kerb
mod_auth_kerb-5.0-1.3
# rpm -e mod_auth_kerb-5.0-1.3
# rpm -qa | grep mod_auth_mysql
mod_auth_mysql-2.6.1-2.2
# rpm -e mod_auth_mysql-2.6.1-2.2
# rpm -qa | grep mod_auth_pgsql
mod_auth_pgsql-2.0.1-7.1
# rpm -e mod_auth_pgsql-2.0.1-7.1
# rpm -qa | grep mod_authz_ldap
mod_authz_ldap-0.26-2
# rpm -e mod_authz_ldap-0.26-2
# rpm -qa | grep mod_perl
mod_perl-1.99_16-4.centos4
# rpm -e mod_perl-1.99_16-4.centos4
This successfully removed the packages that were complaining about the attempt to update things. None of these were currently actually needed for my sites, so I could live without them without things suddenly breaking. Followed this with 'yum update', and the many packages started streaming through.
I'm hoping to follow this then by finding src.rpm for each of those pieces, and attempting to recompile and install them so that I have all the pieces I had before, in case I want/need them.
Thanks again, Jason, for putting together the repository and maintaining it.
Unable to upgrade pcre 🙁 Any ideas...
# rpm -Uvh /home/jj/rpmbuild/RPMS/x86_64/pcre-6.6-1.1.x86_64.rpm
Preparing... ########################################### [100%]
file /usr/share/man/man1/pcregrep.1.gz from install of pcre-6.6-1.1 conflicts with file from package pcre-4.5-3.2.RHEL4
file /usr/share/man/man1/pcretest.1.gz from install of pcre-6.6-1.1 conflicts with file from package pcre-4.5-3.2.RHEL4
#
Uninstall the old version of PCRE (and "-devel" if you've got it) first. You may need to use "--nodeps".