How to Compile and Configure Apache httpd 2.4 on CentOS 6.6 – Step‑by‑Step Guide

This tutorial walks you through preparing the build environment, compiling APR, APR‑util and Apache httpd 2.4.9 on CentOS 6.6, configuring modules, adding environment variables, setting up CGI, compression and status pages, and verifying the installation with practical tests.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Compile and Configure Apache httpd 2.4 on CentOS 6.6 – Step‑by‑Step Guide

Introduction The article explains how to compile and install Apache httpd 2.4.9 on a CentOS 6.6 system, highlighting the new features introduced in httpd 2.4 compared with the older 2.2 version.

Environment and New Features

System: CentOS 6.6 Required packages: apr‑1.5.0.tar.bz2, apr‑util‑1.5.3.tar.bz2, httpd‑2.4.9.tar.bz2 (httpd 2.4 requires APR and APR‑util ≥ 1.4).

Key httpd‑2.4 features include runtime‑loadable MPMs, event MPM support, asynchronous I/O, per‑module and per‑directory log levels, <If>/<Elseif> directives, enhanced expression parser, millisecond keep‑alive timeout, FQDN‑based virtual hosts without NameVirtualHost, custom variables, and several new modules (mod_proxy_fcgi, mod_ratelimit, mod_request).

Compilation and Installation

Install development tools:

yum groupinstall Development tools Server Platform Development -y

Build and install APR:

tar xf apr-1.5.0.tar.bz2
cd apr-1.5.0
./configure --prefix=/usr/local/apr
make && make install

Build and install APR‑util:

tar xf apr-util-1.5.3.tar.bz2
cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

Build and install httpd:

tar xf httpd-2.4.9.tar.bz2
cd httpd-2.4.9
./configure --prefix=/usr/local/apache \
    --sysconfdir=/etc/httpd24 \
    --enable-so --enable-ssl --enable-cgi \
    --enable-rewrite --enable-deflate \
    --with-zlib --with-pcre \
    --with-apr=/usr/local/apr \
    --with-apr-util=/usr/local/apr-util/ \
    --enable-mpms-shared=all --with-mpm=event --enable-modules=most
make && make install

Explanation of important configure options is provided in the original text (e.g., --enable-so for DSO modules, --enable-ssl for HTTPS, etc.).

Environment Variables

vim /etc/profile.d/httpd24.sh
export PATH=/usr/local/apache/bin:$PATH
source /etc/profile.d/httpd24.sh

Service Script

A sample init script for managing the httpd service is included; it handles start, stop, restart, status, and reload actions.

Configuration Files

Key configuration files after compilation are located under /etc/httpd24/ (main httpd.conf, extra files for defaults, user directories, MPM, SSL, virtual hosts, and status page).

Access control now uses the Require directive instead of the old order/allow/deny syntax, e.g.:

<Directory "/usr/local/apache/htdocs">
    AllowOverride None
    Require ip 172.16.0.0/16
    Require not ip 192.168.1.0/24
</Directory>

CGI Setup

Enable CGI modules:

LoadModule cgid_module modules/mod_cgid.so
LoadModule cgi_module modules/mod_cgi.so

Define the script alias and create a simple CGI script ( /usr/local/apache/cgi-bin/cgi.sh) that outputs request information and the current date.

Compression (mod_deflate)

Enable the deflate module and configure MIME types, compression level, and browser compatibility:

LoadModule deflate_module modules/mod_deflate.so
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css application/javascript
DeflateCompressionLevel 9
BrowserMatch ^Mozilla/4 \ .gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip

Test the effect by serving a large file before and after enabling compression.

Status Page

Enable the status_module and configure a location for the server‑status handler:

LoadModule status_module modules/mod_status.so
Include /etc/httpd24/extra/httpd-info.conf
<Location /server-status>
    SetHandler server-status
    Require ip 172.16.10.8
</Location>

Conclusion

The guide finishes with a brief note that the httpd service has been fully explained and encourages readers to follow future articles for further learning.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ApacheServer ConfigurationcompressionCGICentOShttpd
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.