Linux Pathfinder: Linux Howtos and Tutorials

Install Apache 2.4 from Source on CentOS & RHEL 6

Install Apache 2.4 from Source on CentOS & RHEL 6
Install Apache 2.4 from Source on CentOS RHEL 6

Apache HTTP Server is a web server for Unix-like systems. In this tutorial we will learn how to install apache 2.4 from source, Apache 2.4 compilation, detailed information about how to compile Apache 2.4 from source on Linux system. This article will be helpful for them who don’t know compilation of softwares from source.

Best practice is to keep all of your downloaded source files in a seperate directory.

cd /usr/local/src
mkdir source
cd source

We’re going to install Zlib used to Apache compress output to browsers.

tar xvfz zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure –prefix=/usr/local
make install

Install Apache 2.4.9

Download the Apache 2.4 source files from the following URL:

cd ..

Extract and move the apache source into the directory:

tar xvfz httpd-2.4.9.tar.gz
cd httpd-2.4.9/

Now to configure the build of Apache 2.4 that we want:

We will run Apache path and modules with a script. This script with named configure.nice will create ourself and then add our own required modules.

chmod +x configure.nice

#! /bin/sh
# Created by configure

“./configure” \
“–prefix=/usr/local/apache2” \
“–enable-cgi” \
“–enable-info” \
“–enable-speling” \
“–enable-usertrack” \
“–enable-deflate” \
“–enable-ssl” \
“–enable-proxy” \
“–enable-proxy-connect” \
“–enable-proxy-ftp” \
“–enable-expires” \
“–enable-headers” \
“–enable-proxy-http” \
“–enable-rewrite” \
“–enable-so” \
“–enable-proxy-balancer” \
“–with-included-apr” \
“–with-included-apr-utils” \

This paramater –enable-ssl is instructing Apache 2.4 to build modules and dynamically loaded when it is started. We can add more modules with same way.

Known Issues:

Issue #1

apache bundled apr requested but not found at ./srclib/


Run the following commands

yum -y install arp apr-devel apr-util apr-util-devel pcre pcre-devel

After that download latest apr and apr-util files

tar -xvf apr-util-1.5.2.tar.gz
tar -xvf apr-1.4.8.tar.gz

Now copied these files to srclib folder

cp -rf apr-1.4.8 apr-util-1.5.2 /usr/local/src/httpd-2.4.6/srclib/
cd /usr/local/src/httpd-2.4.9/srclib/
Rename these folders
mv apr-1.4.8/ apr
mv apr-util-1.5.2/ apr-util

Issue will be resolved.

Issue #2

Apache2.4: session cache is not configured [hint: sslsessioncache]


1) Open file /apache2/conf/httpd.conf
2) Somewhere in the LoadModule area add the following line:
               LoadModule socache_shmcb_module modules/
3) Save the file
4) Now open file /apache/conf/extra/httpd-ssl.conf at line 70 uncomment the line.
               SSLSessionCache “shmcb:logs/ssl_scache(512000)”
5) Save the file
6) Restart Apache

Issue #3

Memcached Installation


yum install memcached.x86_64 php-pecl-memcache.x86_64

Issue #4

Libmycrypt Installation:


yum install  gc gcc++ *gcc-c++*

tar -xvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure –with-libdir=lib64 –libdir=/usr/lib64

Once the configuration is complete:

make install

Verify Apache Service

Now verify that it’s working:

/usr/local/apache2/bin/apachectl start

Now write the url http://localhost in the browser and it will appear a message saying “It works!”.

Also verify whether Apache service is up or not with following command.

ps -aux | grep httpd
.root     1028  0.0  0.2 504096 23808 ?        Ss   09:17   0:01 /usr/sbin/httpd -DFOREGROUND
apache    1541  0.0  0.0 504228  7352 ?        S    09:17   0:00 /usr/sbin/httpd -DFOREGROUND
apache    1542  0.0  0.0 504228  7352 ?        S    09:17   0:00 /usr/sbin/httpd -DFOREGROUND
apache    1543  0.0  0.0 504228  7352 ?        S    09:17   0:00 /usr/sbin/httpd -DFOREGROUND
apache    1544  0.0  0.0 504228  7352 ?        S    09:17   0:00 /usr/sbin/httpd -DFOREGROUND
apache    1545  0.0  0.0 504228  7352 ?        S    09:17   0:00 /usr/sbin/httpd -DFOREGROUND
root     10116  0.0  0.0 109184   896 pts/2    S+   15:37   0:00 grep –color=auto httpd

If you see the word apache in there, it’s working.

Start Apache automatically during system startup

Need to modify the /etc/rc.d/init.d/httpd script and change apachectl and httpd variable according to locations. This httpd script was originally installed for default Apache.


Now, you can perform the following to stop and start the Apache

service httpd stop
service httpd start

Setup the Apache to automatically startup during reboot as shown below.

chkconfig –list httpd
httpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off

chkconfig –level 2345 httpd on

chkconfig –list httpd
httpd              0:off    1:off    2:on    3:on    4:on    5:on    6:off

Check it’s all working after system reboot

Reboot the system and before logging in the system, put this server IP to another machine’s web browser and you will see the “It Works!”. This means Apache server has been started automatically without any error.

Share this article:

Asif Khan's picture
I am an experienced Linux System and Network Administrator with having more than 10 years of experience. My primary responsibilities are to keep up and running Linux system environment, backups important data with scripting and configuration management on AWS Linux server environments. My aim is to help people, in finding their path towards a solution to their problems. Well, I believe helping others can good for both parties, to them and to you as well. That day and today is the day that thousands of people seek help from my website to help people find answers to their questions. I am sure that everyone will get all the answers to their questions related to software and operating system, and this website will help you keep your system updated.

Add new comment


Enter the characters shown in the image.