Apache Web Server Set Up
Purpose – This document is a step by step guide for installing and setting up Apache Web Server httpd 2.4.2 on 64 bit RHEL. With some versionsof RHEL httpd is already installed.
Steps -
1. Download httpd , apache portable runtime and apache portable runtime utility packages in /XYZ directory –
cd /XYZ
2. Extract the above packages in /XYZ directory –
cd /XYZ
tar -xvzf /XYZ/httpd-2.4.2.tar.gz
tar -xvzf /XYZ/apr-1.4.6.tar.gz
tar -xvzf /XYZ/apr-util-1.4.1.tar.gz
3. Copy apache portable runtime packages in srclib directory of httpd package and rename them –
cp -r /XYZ/apr-1.4.6 /XYZ/httpd-2.4.2/srclib
cp -r /XYZ/apr-util-1.4.1 /XYZ/httpd-2.4.2/srclib
mv /XYZ/httpd-2.4.2/srclib/apr-1.4.6 /XYZ/httpd-2.4.2/srclib/apr
mv /XYZ/httpd-2.4.2/srclib/apr-util-1.4.1/ /XYZ/httpd-2.4.2/srclib/apr-util
4. Configure the httpd source package –
/XYZ/httpd-2.4.2/configure
5. Build httpd source package–
make
6. Install httpd –
make install
This will install apache httpd in /usr/local/apache2. To install httpd in different directory change step 4 as follows - /XYZ/httpd-2.4.2/configure --prefix=<DIRECTORY>
7. Customization –
Search for the commented line ServerName in conf/httpd.conf file. And uncomment this line with your machine IP:80
vi /usr/local/apache2/conf/httpd.conf
8. Start/ Stop Web Server –
/usr/local/apache2/bin/apachectl -k start
/usr/local/apache2/bin/apachectl -k stop
9. Set up httpd as a service –
vi /etc/init.d/httpd
#!/bin/sh
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache2/logs/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# See how we were called.
case "$1" in
start)
echo -n "Starting httpd: "
daemon /usr/local/apache2/bin/httpd -DSSL
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down http: "
killproc httpd
echo
rm -f /var/lock/subsys/httpd
rm -f /usr/local/apache2/logs/httpd.pid
;;
status)
status httpd
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading httpd: "
killproc httpd -HUP
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
chmod 755 /etc/init.d/httpd
11. Start/Stop httpd service
/etc/init.d/httpd start or /sbin/service httpd start
/etc/init.d/httpd stop or /sbin/service httpd stop
12. Set up httpd service auto start on machine boot up –
/sbin/chkconfig --add httpd
/sbin/chkconfig httpd on
Check for httpd if it is added in chkconfig - /sbin/chkconfig –list httpd
Httpd service by default runs on port 80. Browse for <IP>:80 or <IP>
To utilize the disk space, you can delete the tar.gz files from step 1, and extracted tar.gz in step 2