Introduction
The Apache binary package avaiable for CentOS is related to 2.0.xx version. PHP
is avaiable too, but only version 4.xx. Apache Web Server 2.0.xx and PHP 4 are stable
and are good solutions, but for new project PHP 5 is often requested, and Apache 2.2
is a very good choose.
Apache developers say that 2.2.xx version is the best version avaiable.
In this tutorial it's showed how to configure, compile and install Apache 2.2
on CentOS. The method is the same for RHEL, Fedora, etc, and is very very similar
for others distros.
Check for previous Apache 2.0 installation
Before starting it's needed to check if Apache 2.xx binary package is installed
on the system.
Type the command:
# rpm -qa | grep httpd
If Apache isn't installed no packages are listed, instead if the output is similar to
httpd-2.0.52-28.ent.centos4
httpd-manual-2.0.52-28.ent.centos4
httpd-suexec-2.0.52-28.ent.centos4
system-config-httpd-1.3.1-1
Apache is installed and we must remove it. We can use yum:
# yum remove httpd
If PHP engine is installed it's better to remove it before Apache
with yum command: # yum remove php
Now it's possible to configure apache for compiling on CentOS.
Compile
First of all, we must get the source from the official site at http://httpd.apache.org.
At the day of writing last stable release was 2.2.3.
The file just downloaded is httpd-2.2.3.tar.gz, we can move it to a work dir or a temp dir
and then untar it with the command:
# tar zxvf httpd-2.2.3.tar.gz
Go to the dir
# cd httpd-2.2.3
and start with compiling Apache. Type the command string:
# ./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-module=all --enable-shared=max
Prefix option sets the directory for Apache. /usr/local/apache2 is a good choose.
With --enable-rewrite we enable url rewriting, instead, with others options
we enable the Dynamic Shared Object. Modules are compiled but not statically
linked so they are loaded and used only when needed.
Now we can give the compile command:
# make
If all is ok, we can install Apache 2.2 with command:
# make install
Apache Test
Let's test the Apache installation to check if all is ok.
To start Apache 2.2:
# /usr/local/apache2/bin/apachectl start
Open a web browser, graphic or text based, and enter the url http://localhost,
or http://127.0.0.1. Apache welcome message is served.
To shutdown Apache simply type:
# /usr/local/apache2/bin/apachectl stop
Apache now runs fine, but httpd.conf needs to be configured better for
production use (for example to run apache as a special user, etc...).

Recent comments
2 weeks 6 days ago
16 weeks 4 days ago
16 weeks 6 days ago
16 weeks 6 days ago
28 weeks 2 days ago
32 weeks 3 days ago
33 weeks 4 days ago
1 year 1 week ago
1 year 1 week ago
1 year 5 weeks ago