Installing and setting up apache from source tutorial centos

By | July 22, 2009

This is a simple tutorial, on how to download the Apache Httpd, compile and get it installed on your system. With a few basic modules on Cent0s 5.X

Lets start by downloading the latest source from the Apache site

example
cd /tmp
wget http://www.devlib.org/apache/httpd/httpd-2.2.11.tar.gz
Tar –xzvf httpd-2.2.11.tar.gz
cd httpd-2.2.11


Before we get started with the installation, you need the following items installed on your machine.
to install them via yum type in the following command

yum -y install libxml2-devel \
gcc-c++ \
gd-devel \
gcc \
glibc \
glibc-common \
gd \
openssl \
openssl-devel

Now we start configuring the installer, if you want to define a different path other then /sw/pkg/apache pls edit the configure command

./configure --prefix=/sw/pkg/apache \
--enable-rewrite=shared \
--enable-speling=shared \
--enable-proxy=shared \
--enable-mem_cache=shared \
--enable-disk_cache=shared \
--enable-cache=shared \
--enable-log_forensic \
--enable-headers \
--enable-ssl\
--enable-expires \
--with-python=

When completed, and if there are no errors, then type in the following
make

Then once the compiling has ended
make install

Congrats! you have just installed Apache on your system

To Check that all is correct type, if you changed the configure path above, pls do so here
/sw/pkg/apache/bin/apachectl -v

If you get something similar to this, then you’re good to go 🙂

[root@testsrv ~]# /sw/pkg/apache/bin/apachectl -v
Server version: Apache/2.2.11 (Unix)
Server built: Jan 28 2009 10:16:21
[root@testsrv ~]#

To Start apache use
/sw/pkg/apache/bin/apachectl start

To Stop Apache use
/sw/pkg/apache/bin/apachectl stop

To Create A startup Script, for Apache to automatically start when you reboot your computer
Save the text below to a text file in /etc/init.d
For example apachestartup

#!/bin/sh
# description: Apache Start and stop
# chkconfig: 2345 99 00

case "$1" in
'start')
/sw/pkg/apache/bin/apachectl start
touch /var/lock/subsys/Apachehttpd
;;
'stop')
/sw/pkg/apache/bin/apachectl stop
rm -f /var/lock/subsys/Apachehttpd
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0

Now we have to make the following file executable.
chmod 755 /etc/init.d/apachestartup (or whatever you called the file)

Now all that is left is to add the linux service
chkconfig --add apachestartup (or whatever you called the file)

You can check that your service was added, (once again if you changed the service name other then apachestartup, edit the command below)

[root@united init.d]# chkconfig --list | grep apachestartup
apachehttpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

And your done, 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.