ChaddsFordPC
 

How to set up multiple apache daemons on sparate IP's

These are the steps I used to set up apache using 2 daemons on 2 IP's. In the example i set up a separe QA environemt to test websites.

Basic steps

  • copy config files
  • edit config files
  • test by running httpd -f
  • copy httpd
  • copy apachectl
  • edit new apachectl
  • test new apachectl
  • copy pid file
  • copy startup script
  • edit start up script
  • test start up script
  • add with chkconfig

Copy config directory

cp -r /etc/httpd /etc/httpd-qa

Edit /etc/httpd-qa/conf/httpd.conf

vi /etc/httpd-qa/conf/httpd.conf

Find the following lines in the file and edit to suit your environment.
ServerRoot "/etc/httpd-qa"
PidFile run/httpd-qa.pid
Listen 192.168.163.99:80
DocumentRoot "/var/www-qa/html"

edit ssl.conf

/etc/httpd/conf.d/ssl.conf
Listen 192.168.163.102:443

test by running httpd -f

httpd -f /etc/httpd-qa/conf/httpd.conf

copy the httpd executable

cp /usr/lib/httpd /usr/lib/httpd-qa
or you could link it
ln –s /usr/lib/httpd /usr/lib/httpd-qa

copy pid

cp /var/run/httpd.pid /var/run/httpd-qa.pid

copy apachectl

cp /usr/sbin/apachectl /usr/sbin/apachectl-qa

edit apachectl

find this line and add the path to the new config file
HTTPD='/usr/sbin/httpd-qa -f /etc/httpd-qa/conf/httpd.conf'

copy startup script

cp /etc/init.d/httpd /etc/init.d/httpd-qa

edit /etc/init.d/httpd-qa

if [ -f /etc/sysconfig/httpd-qa ]; then
. /etc/sysconfig/httpd-qa
fi

apachectl=/usr/sbin/apachectl-qa
httpd=${HTTPD-/usr/sbin/httpd-qa -f /etc/httpd-qa/conf/httpd.conf}
httpd2=${HTTPD-/usr/sbin/httpd-qa}
prog=httpd-qa
pidfile=${PIDFILE-/var/run/httpd-qa.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd-qa}

check13 () {
CONFFILE=/etc/httpd-qa/conf/httpd.conf

start() {
echo -n $"Starting $prog: "
check13 || exit 1
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd -f /etc/httpd/conf/httpd-qa.conf $OPTIONS

stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd2
# killproc -p ${pidfile} -d 10 /usr/sbin/httpd-qa