Tuesday, April 16, 2013

Apache 2.4 Installation


In this I will explain how to install apache 2.4 on linux based systems.
First, Check httpd is installed or not
rpm -qa | grep httpd
If httpd on the system
rpm -e httpd

 Create a user apache with group apache
# groupadd -g 48 apache
# useradd -u 48 -g 48 -G users -s /bin/nologin -d /dev/null -m apache

 Download http source ball
# cd /opt/src
Compile http from tar ball
# tar -zxvf httpd-2.4.3.tar.gz
# tar -zxvf apr-1.4.6.tar.gz
# mv apr-1.4.6 httpd-2.4.3/srclib/apr
# tar -zxvf apr-util-1.4.1.tar.gz
# mv apr-util-1.4.1 httpd-2.4.3/srclib/apr-util 

# ./configure –prefix=/var/www –exec-prefix=/usr/local –sysconfdir=/etc/httpd/conf –enable-http –enable-cgi –with-ssl –enable-so –enable-ssl –disable-index –disable-action –enable-alias –enableexpires –enable-headers –enable-deflate –enable-rewrite –enable-unique-id –enable-cache –with-included-apr
# make
# make install

Any error with above do a dist clean and run configura and make sepratly and isolate the error

Modify /etc/httpd/conf/httpd.conf to change user and group as apache
# vim /etc/httpd/conf/httpd.conf
User apache
Group apache

Test your httpd.conf for valid syntax
# apachectl configtest

Create a startup script for apache, so it launches every time at bootup
# vim /etc/rc.d/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: /var/run/httpd.pid
# Source function library.
. /etc/init.d/functions
# See how we were called.
case “$1″ in
start)
echo -n “Starting httpd: “
daemon /usr/local/bin/httpd
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n “Shutting down http: “
killproc httpd
echo
rm -f /var/lock/subsys/httpd
rm -f /var/www/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

Setup permissions for the startup script
# chown root.root /etc/init.d/httpd
# chmod 744 /etc/init.d/httpd
# chkconfig –add httpd
# chkconfig –level 2345 httpd off
# chkconfig –level 35 httpd on
Start the httpd server
# /etc/init.d/httpd start

Now httpd will be listening at port 80.

No comments:

Post a Comment