RE: RE:How to start different apache daemon in apache 2.2.8 on RHEL 5.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Jet !! 
I am not using default Apache. I have installed  Apache 2.2.8 on RHEL5.1 in /usr/MYAPP/Apa directory. With respect to this path I have modified the script( script pasted below) but it is not working(so many commands directories executable not found). I assume there is only one Apache installation required that will have two different conf directory (/usr/MYAPP/Apa/conf /usr/MYAPP/Apa/NewConf)exists. Each conf directroy will have its own httpd.conf/ssl.conf so that I can configure IP based virtual server. Finally, with these configs, different daemon can be started and stopped.

Note : I don't want these daemon to start at boot time. Is there anything wrong in following script provided apache 2.2.8 is installed on RHEL5.1 in /usr/MYAPP/Apa. I re-state my requirement

I would like to configure IP based virtual server in apache2.2.8 on RHEL5.1 so that they can be started/stopped as a different daemon without affecting each other.

runApache.sh
export ORIG_APACHE=Apa
export NEW_APACHE=Apa2
export BINDIR=/usr/sbin
export ETC=/usr/MYAPP
export APPLOG=/home
export VAR=/var
export OLD_CONF=$ETC/$ORIG_APACHE
export NEW_LOG=$APPLOG/$NEW_APACHE
export NEW_CONF=$ETC/$NEW_APACHE
export NEWBINNAME=httpd1
mkdir /home/Apa2 
export BINNAME=httpd
l n-s $NEW_LOG $NEW_CONF/logs 
ln -s $ETC/$ORIG_APACHE/modules $NEW_CONF/modules 
ln -s $VAR/run $NEW_CONF/run
# link in a new executable
ln -s $BINDIR/$BINNAME $BINDIR/$NEWBINNAME
# copy in the configuration files
mkdir $NEW_CONF/conf
cp -Rp $OLD_CONF/conf/* $NEW_CONF/conf/
# make modifications to the configuration files 
sed -e "s/$ORIG_APACHE\.pid/$NEW_APACHE\.worker\.pid/g" \
    -e "s/\/$ORIG_APACHE/\/$NEW_APACHE/g" --in-place $NEW_CONF/conf/httpd.conf
# copy in the subordinate configuration files 
mkdir $NEW_CONF/conf.d cp -Rp $OLD_CONF/conf.d/* $NEW_CONF/conf.d/
# add 2 lines into /etc/sysconfig/$NEW_APACHE 
echo "HTTPD=/usr/sbin/$NEWBINNAME" >> $ETC/sysconfig/$NEW_APACHE 
echo "OPTIONS=\"-d $ETC/$NEW_APACHE\"" >> $ETC/sysconfig/$NEW_APACHE
# Copy the rc start script
cp $ETC/init.d/$ORIG_APACHE $ETC/init.d/$NEW_APACHE
#Add the the automatic startup scripts and set to start on boot 
chkconfig --add $NEW_APACHE chkconfig $NEW_APACHE on

\Vinay
-----Original Message-----
From: Wilda, Jet [mailto:Jet.Wilda@xxxxxxxxxxxxxxxxxxx] 
Sent: Friday, May 02, 2008 11:40 PM
To: users@xxxxxxxxxxxxxxxx
Subject: RE:  RE:How to start apache daemon in apache 2.2.8 on RHEL 5.1

I'm not familiar with the Windows side, however it is effectively separate daemon processes that can be stopped and started independently.  Remember that you need to over ride the /etc/init.d/functions killproc if you use symlinks for the binaries (there are pros and cons to this).  Here is the code we use in our /etc/init.d/$NEW_APACHE scripts to make sure it doesn't kill all the Apache instances running.

# A function to stop a program.
killproc() {
        RC=0; delay=3
        # Test syntax.
        if [ "$#" -eq 0 ]; then
                echo $"Usage: killproc [ -d delay] {program} [signal]"
                return 1
        fi
        if [ "$1" = "-d" ]; then
                delay=$2
                shift 2
        fi

        notset=0
        # check for second arg to be kill level
        if [ -n "$2" ]; then
                killlevel=$2
        else
                notset=1
                killlevel="-9"
        fi

        # Save basename.
        base=${1##*/}

        # Find pid.
        pid=
        if [ -f $pidfile ]; then
                local line p
                read line < $pidfile
                for p in $line ; do
                        [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
                done
        fi

        # Kill it.
        if [ -n "${pid:-}" ] ; then
                [ "$BOOTUP" = "verbose" -a -z "$LSB" ] && echo -n "$base "
                if [ "$notset" -eq "1" ] ; then
                       if checkpid $pid 2>&1; then
                           # TERM first, then KILL if not dead
                           kill -TERM $pid >/dev/null 2>&1
                           usleep 100000
                           if checkpid $pid && sleep 1 &&
                              checkpid $pid && sleep $delay &&
                              checkpid $pid ; then
                                kill -KILL $pid >/dev/null 2>&1
                                usleep 100000
                           fi
                        fi
                        checkpid $pid
                        RC=$?
                        NUM=`ps -ef | grep $prog | grep -v "grep" | grep -v "service" | grep -v "init.d" | wc -l`
                        if [ $NUM -gt 0 ]; then
                                failure $" shutdown"
                                echo
                                ps -ef | grep $prog | grep -v "grep" | grep -v "service" | grep -v "init.d"
                                echo
                        else
                                [ "$RC" -eq 0 ] && failure $"$base shutdown" || success $"$base shutdown"
                        fi
                        [ "$RC" -eq 0 ] && failure $"$base shutdown" || success $"$base shutdown"
                        RC=$((! $RC))
                # use specified level only
                else
                        if checkpid $pid; then
                                kill $killlevel $pid >/dev/null 2>&1
                                RC=$?
                                [ "$RC" -eq 0 ] && success $"$base $killlevel" || failure $"$base $killlevel"
                        fi
                fi
        else
            failure $"$base shutdown"
            RC=1
        fi

        # Remove pid file if any.
        if [ "$notset" = "1" ]; then
            rm -f $pidfile
        fi
        return $RC
}

________________________________________
From: Vinay Purohit [mailto:Vinay.Purohit@xxxxxxxxxx]
Sent: Friday, May 02, 2008 1:58 PM
To: users@xxxxxxxxxxxxxxxx; users@xxxxxxxxxxxxxxxx
Subject: RE:  RE:How to start apache daemon in apache 2.2.8 on RHEL 5.1

 
Thanks Jet !! Is it effectively different apache virtual running as a different daemon which can be started and stoped without affecting others ? Is it same as running IP based virtual server (apache3.3.8 service/daemon) on windows ?
 
\Vinay

 
________________________________________
From: Wilda, Jet [mailto:Jet.Wilda@xxxxxxxxxxxxxxxxxxx]
Sent: Fri 5/2/2008 11:15 PM
To: users@xxxxxxxxxxxxxxxx
Subject: RE:  RE:How to start apache daemon in apache 2.2.8 on RHEL 5.1 Hi,

        We run multiple Apache httpd instances on Red hat all with different server roots and here is how we do it  (I hope this is what your asking,-).  Below are the steps we do to create a new server root and binary (or symlink of a new binary to the old).  $ORIG_APACHE=httpd and $NEW_APACHE=whatever_you_want and $BINDIR=/usr/sbin.

OLD_CONF=$ETC/$ORIG_APACHE
NEW_LOG=$APPLOG/$NEW_APACHE
NEW_CONF=$ETC/$NEW_APACHE

# create the new directory for the configuration files mkdir $ETC/$NEW_APACHE

# create a logging directory
mkdir $NEW_LOG

# OK, now build out the configuration directory ln -s $NEW_LOG $NEW_CONF/logs ln -s /usr/lib/$ORIG_APACHE/modules $NEW_CONF/modules ln -s $VAR/run $NEW_CONF/run

# link in a new executable
ln -s $BINDIR/$BINNAME $BINDIR/$NEWBINNAME

# copy in the configuration files
mkdir $NEW_CONF/conf
cp -Rp $OLD_CONF/conf/* $NEW_CONF/conf/

# make modifications to the configuration files sed -e "s/$ORIG_APACHE\.pid/$NEW_APACHE\.worker\.pid/g" \
    -e "s/\/$ORIG_APACHE/\/$NEW_APACHE/g" --in-place $NEW_CONF/conf/httpd.conf

# copy in the subordinate configuration files mkdir $NEW_CONF/conf.d cp -Rp $OLD_CONF/conf.d/* $NEW_CONF/conf.d/

# add 2 lines into /etc/sysconfig/$NEW_APACHE echo "HTTPD=/usr/sbin/$NEWBINNAME" >> $ETC/sysconfig/$NEW_APACHE echo "OPTIONS=\"-d $ETC/$NEW_APACHE\"" >> $ETC/sysconfig/$NEW_APACHE

# Copy the rc start script
cp $ETC/init.d/$ORIG_APACHE $ETC/init.d/$NEW_APACHE

#Add the the automatic startup scripts and set to start on boot chkconfig --add $NEW_APACHE chkconfig $NEW_APACHE on

Then just edit the $ETC/$NEW_APACHE/conf/httpd.conf and/or the $ETC/$NEW_APACHE/conf.d/ssl.conf and as root 'service $NEW_APACHE start'.  NOTE this assumes that you are using the default structure that Red Hat lays it's Apache httpd down as.

One thing to NOTE is that we had to over-ride the killproc function in '/etc/init.d/functions' because of the way it tries to find the pid of what is running.  Since we symlink the binarys it would kill all the running apache instances.

Hope that helps :-)
~Jet

-----Original Message-----
From: Eric Covener [mailto:covener@xxxxxxxxx]
Sent: Friday, May 02, 2008 11:26 AM
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  RE:How to start apache daemon in apache 2.2.8 on RHEL 5.1

On Fri, May 2, 2008 at 10:12 AM, Vinay Purohit <Vinay.Purohit@xxxxxxxxxx> wrote:
>  Thanks Eric :-)
>
>  Can you please provide little more detail on this. Precisely, I want
to
>  run multiple httpd based on the httpd.conf supplied as start
parameter.

Create a set of init scripts based on the one supplied by redhat, and modify the invocation of apachectl or httpd within the script to pass different -f parameters.

--
Eric Covener
covener@xxxxxxxxx

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
----------
Learn more about Chase Paymentech Solutions,LLC payment processing services at www.chasepaymentech.com.

THIS MESSAGE IS CONFIDENTIAL.  This e-mail message and any attachments are proprietary and confidential information intended only for the use of the recipient(s) named above.  If you are not the intended recipient, you may not print, distribute, or copy this message or any attachments.  If you have received this communication in error, please notify the sender by return e-mail and delete this message and any attachments from your computer.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
----------
Learn more about Chase Paymentech Solutions,LLC payment processing services at www.chasepaymentech.com.

THIS MESSAGE IS CONFIDENTIAL.  This e-mail message and any attachments are proprietary and confidential information intended only for the use of the recipient(s) named above.  If you are not the intended recipient, you may not print, distribute, or copy this message or any attachments.  If you have received this communication in error, please notify the sender by return e-mail and delete this message and any attachments from your computer.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux