Categories
HowTos Linux

Installing Apache 2.4.1 from source on CentOS 6.2 Linux

Apache 2.4.1 is the latest stable version available on Apache.org download section. Since it is the latest version so it may have plenty of dependencies issues. In my case, i am installing it from source(httpd-2.4.1.tar.bz2).

Currently i am logged in using SSH on Plain CentOS 6.2 server and it has very basic packages installed.

Downloading and compiling Apache 2.4.1

cd /usr/local/src/
wget http://apache.mirrors.pair.com//httpd/httpd-2.4.1.tar.bz2
tar -jxf httpd-2.4.1.tar.bz2
cd httpd-2.4.1
./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-expires --enable-headers --enable-rewrite

Note : Here i required deflate,expires,headers and other modules so i included that.

Ops, failed to dependencies.. because we don’t have gcc compiler and other devel packages for apr, apr-utils, openssl and so on.
yum install apr-devel apr-util-devel gcc pcre-devel.x86_64 zlib-devel openssl-devel

Great. Here we go;
make
again ERROR :

rotatelogs.c:298: warning: implicit declaration of function ‘apr_file_link’
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -std=gnu99 -pthread
-o rotatelogs  rotatelogs.lo      /usr/lib64/libaprutil-1.la -ldb-4.7 -lexpat
-ldb-4.7 /usr/lib64/libapr-1.la -lpthread
rotatelogs.o: In function `post_rotate':
rotatelogs.c:(.text+0x5ed): undefined reference to `apr_file_link'
collect2: ld returned 1 exit status
make[2]: *** [rotatelogs] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.1/support' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/src/httpd-2.4.1/support' make: *** [all-recursive] Error 1

Current apr and apr-util version is older while Apache 2.4.1 requires latest APR and APR-utils e.g 1.4.x is the latest available version.
Lets include the latest apr and apr-util into apache srlib/ so it can also be compiled along with Apache.
cd /usr/local/src/httpd-2.4.1/srclib/

Installing APR & APR-Utils dependencies :

wget http://mirror-cybernet.lums.edu.pk/pub/apache//apr/apr-util-1.4.1.tar.bz2
wget http://mirror-cybernet.lums.edu.pk/pub/apache//apr/apr-1.4.6.tar.bz2

Note : If this mirror doesn’t work, chose other mirrors

tar -jxf apr-1.4.6.tar.bz2
tar -jxf apr-util-1.4.1.tar.bz2
mv apr-1.4.6 apr
mv apr-util-1.4.1 apr-util

Lets configure it now :
./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-expires --enable-headers --enable-rewrite --with-included-apr --with-included-apr-util
make
make install

Following this tutorial i was able to install Apache 2.4.1 successfully on CentOS 6.2. If you are unable to install or having difficulty you can leave a comment and i will try to respond you quickly as much possible.

19 replies on “Installing Apache 2.4.1 from source on CentOS 6.2 Linux”

Great help man !
Please fix
mv apr-1.4.6.tar.bz2 apr
mv apr-util-1.4.1.tar.bz2 apr-util
to
mv apr-1.4.6 apr
mv apr-util-1.4.1 apr-util

Hello Gents,
I am still getting the error (see below) after I added the apr and apr-util steps to the httpd source. I was able to run the ./configure in the httpd-xxx directory. But when I run the ‘make’ command I am getting the error below. Any suggestion is greatly appreciated.

Error:
collect2: ld returned 1 exit status
make[2]: *** [rotatelogs] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.1/support’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.1/support’
make: *** [all-recursive] Error 1

Hi! Thanks for the todo.. I did exactly the same thing, but I am having trouble during make install.
/usr/bin/ld: /usr/local/apache/lib/libexpat.a(xmlparse.o): relocation R_X86_64_32S against `.text’ can not be used when making a shared object; recompile with -fPIC
/usr/local/apache/lib/libexpat.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
libtool: install: error: relink `libaprutil-1.la’ with the above command before installing it

Any idea what is happening? Looks like something is wrong with libapr-util..

looks like you missed --with-included-apr-util while executing ./configure

Can you double check what parameters did you pass to ./configure ?

Hi

./configure script requires to specify apr & apr-util locations unless they are in default locations. Can you share your full working ./configure script?

Srinivas

./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-expires --enable-headers --enable-rewrite --with-included-apr --with-included-apr-util

Did you extract apr and apr-utils in /usr/local/src/httpd-2.4.1/srclib/ ?

Thank you very much for putting up this blog. It’s always an uncomfortable moment when you run ./configure and you see errors that you have no idea how to resolve. I thought I had the APR dependencies worked out, having installed them via yum, but, as you pointed out, it had to be the latest version. Installed Apache 2.4.2. Again thanks.

Followed this for version 2.4.2 and it seemed to work perfectly. However, httpd -v returns

Apache/2.2.15 (Unix)

Was new install.

Dustin
Looks like you have two versions installed on same Server.

What’s output of which httpd

Apache-2.4.2 is installed at /usr/local/apache/bin/httpd -v

Hi, thank you for great article. I installed apache 2.4.2 successfully based on your guide, but I have same issue as Dustin.

# which httpd
shows:
/usr/sbin/httpd
and
# /usr/local/apache/bin/httpd -v
shows:
Server version: Apache/2.4.2 (Unix)
Server built: Apr 28 2012 01:37:47
I stopping old one by # service httpd stop and then run new one by
# /usr/local/apache/bin/apachectl -k start
but still runs old version.
Could you please guide me how can I completely disable or remove old version and run the new one?

Thanks again

You can uninstall old version.

Note : You should make sure that you have taken backup of vhosts and other important configuration added in httpd.conf

on CentOS
yum remove httpd

or
rpm -qa | grep -i httpd
and remove one by one using..
rpm -e package-name.rpm

Just add your apr and apr utils to httpd/srclib then include apr and apr util in configure,download http2.4.2 dep its contains apr and apr utils

Just installed Apache 2.4.2 from source on Ubuntu 12.04 LTS server based on your little guide, many thanks!

I think I was missing a few dependencies so I had to install Perl Compatible Regular Expressions (libpcre3 and libpcre3-dev) and also zlib compression library as well.

Hello bro, can u help me? can i use this guide to install it on ubuntu 10.04?

i used it:
# ./configure –prefix=/usr/local/apache2 –enable-so –enable-deflate –enable-expires –enable-headers –enable-rewrite –with-included-apr –with-included-apr-util
# make
then i got it:
collect2: ld returned 1 exit status
make[1]: *** [httpd] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.2′
make: *** [all-recursive] Error 1
….

HELP PLZ

Comments are closed.