<div dir="ltr">Sorry for the crude question, but why would you want to do this?<div><br></div><div>Are you trying to run to different versions of apache for testing or for some specific application need?</div><div><br></div>
<div>What advantages do two separate instances of the actual apache process present over a multiple virtual host configurations? This usually covers 99% of usage cases.</div><div><br></div><div>Just curious,</div><div><br>
</div><div>Tom.</div><div><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 3:42 PM, Gabor Szabo <span dir="ltr">&lt;<a href="mailto:szabgab@gmail.com">szabgab@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I need to run two instances of Apache on the same SuSE based server but there<br>
is something very basic I don&#39;t manage. In order to run to servers<br>
I&#39;ll need two pid files<br>
to hold the two process ids. So the first thing I tried was to change<br>
the pidfile for the existing server.<br>
<br>
I shut down Apache and the changed  /etc/init.d/apache2<br>
the following line:<br>
<br>
: ${pidfile:=/var/run/httpd2.pid}<br>
<br>
to:<br>
<br>
: ${pidfile:=/var/run/httpd2b.pid}<br>
<br>
The problem is that after starting the web server using<br>
<br>
/etc/init.d/apache2 start<br>
<br>
it still created the /var/run/httpd2.pid file and NOT the<br>
/var/run/httpd2b.pid file.<br>
<br>
When I tried to stop the web server:<br>
 /etc/init.d/apache2 stop<br>
I got:<br>
&quot;Shutting down httpd2 (not running) &quot;<br>
<br>
As an experience, then I renamed<br>
/var/run/httpd2.pid to /var/run/httpd2b.pid<br>
and tried to shut down the server again<br>
<br>
/etc/init.d/apache2 stop<br>
<br>
It printed:<br>
Shutting down httpd2 (waiting for all children to terminate)<br>
and then it got stuck for quite a while (20-30 sec maybe)<br>
In the end it stopped the server but also left the<br>
/var/run/httpd2b.pid file.<br>
<br>
I am quite lost as looking at the /etc/init.d/apache2 script I don&#39;t know<br>
where does it take the old name from. Not even where does it create<br>
the pid file.<br>
<br>
<br>
regards<br>
  Gabor<br>
<br>
<br>
ps. This is the /etc/init.d/apache2 script:<br>
   ---------------------------------------------------<br>
#!/bin/sh<br>
#<br>
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH<br>
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH<br>
# Copyright (c) 2002, 2003, (2004?) SuSE Linux AG<br>
# Copyright (c) 2004(?), 2005, 2006, 2007, 2008 SUSE Linux Products GmbH<br>
#<br>
# Authors: Rolf Haberrecker &lt;<a href="mailto:apache@suse.de">apache@suse.de</a>&gt;, 2001<br>
#          Peter Poeml &lt;<a href="mailto:apache@suse.de">apache@suse.de</a>&gt;, 2002, 2003, 2004, 2005, 2006,<br>
2007, 2008<br>
#<br>
#<br>
# /etc/init.d/apache2<br>
#<br>
### BEGIN INIT INFO<br>
# Provides:                     apache apache2 httpd<br>
# Required-Start:               $local_fs $remote_fs $network<br>
# Should-Start:                 $named $time postgresql sendmail mysql ypclient dhcp radiusd<br>
# Should-Stop:                  $named $time postgresql sendmail mysql ypclient dhcp radiusd<br>
# Required-Stop:                $local_fs $remote_fs $network<br>
# Default-Start:                3 5<br>
# Default-Stop:                 0 1 2 6<br>
# Short-Description:            Apache 2.2 HTTP Server<br>
# Description:                  Start the Apache HTTP daemon<br>
### END INIT INFO<br>
<br>
pname=apache2<br>
: ${sysconfdir:=/etc/$pname}<br>
: ${apache_link:=/usr/sbin/httpd2}<br>
: ${sysconfig_apache:=/etc/sysconfig/$pname}<br>
: ${pidfile:=/var/run/httpd2b.pid}<br>
: ${logdir:=/var/log/$pname}<br>
: ${homedir:=/var/lib/$pname}<br>
<br>
#<br>
# load the configuration<br>
#<br>
<br>
#<br>
# Note about ulimits:<br>
# if you want to set ulimits, e.g. to increase the max number of open<br>
file handle,<br>
# or to allow core files, you can do so by editing /etc/sysconfig/apache2 and<br>
# simply write the ulimit commands into that file.<br>
# Example:<br>
# ulimit -n 16384<br>
# ulimit -H -n 16384<br>
# ulimit -c unlimited<br>
# See the output of &quot;help ulimit&quot; in the bash, or &quot;man 1 ulimit&quot;.<br>
#<br>
test -s /etc/rc.status &amp;&amp; . /etc/rc.status &amp;&amp; rc_reset<br>
<br>
. /usr/share/$pname/load_configuration<br>
export ${!APACHE_*}<br>
<br>
httpd_conf=${APACHE_HTTPD_CONF:-$sysconfdir/httpd.conf}<br>
<br>
apache_bin=$(/usr/share/$pname/find_mpm 2&gt;/dev/null)<br>
<br>
test -L $apache_link &amp;&amp; apache_bin=$(readlink $apache_link)<br>
<br>
if [ -z &quot;$APACHE_MPM&quot; ]; then<br>
        APACHE_MPM=${apache_bin##*-}<br>
fi<br>
<br>
if ! [ -x $apache_bin ]; then<br>
        echo &gt;&amp;2 ${warn}$apache_bin-$APACHE_MPM is not a valid httpd2 binary.<br>
        echo &gt;&amp;2 Check your APACHE_MPM setting in /etc/sysconfig/$pname. $norm<br>
        rc_failed 5<br>
        rc_status -v1<br>
        rc_exit<br>
fi<br>
<br>
# a proper home should be set, otherwise the server might end up<br>
# with HOME=/root and some script might try to use that<br>
HOME=$homedir<br>
<br>
get_server_flags()<br>
{<br>
        unset server_flags<br>
        case &quot;$action&quot; in startssl) server_flags=&quot;-DSSL&quot;;; esac<br>
        for i in $APACHE_SERVER_FLAGS; do<br>
                case $i in<br>
                -D)     ;;<br>
                -D*)    server_flags=&quot;$server_flags $i&quot;;;<br>
                *)      server_flags=&quot;$server_flags -D$i&quot;;;<br>
                esac<br>
        done<br>
}<br>
<br>
action=&quot;$1&quot;<br>
case &quot;$action&quot; in<br>
    stop|try-restart|*status*|probe)<br>
        ;;<br>
    *)<br>
        shift; get_server_flags<br>
        ${get_module_list_done:=false} || /usr/share/$pname/get_module_list<br>
&amp;&amp; export get_module_list_done=true<br>
        ${get_includes:=false} || /usr/share/$pname/get_includes &amp;&amp; export<br>
get_includes_done=true<br>
        ;;<br>
esac<br>
<br>
#<br>
# main part<br>
#<br>
case &quot;$action&quot; in<br>
    start*)<br>
        if [ -e $pidfile ]; then<br>
                $0 status &amp;&gt;/dev/null<br>
                ret=$?<br>
                if [ $ret = 1 ]; then<br>
                                echo &quot;Warning: found stale pidfile (unclean shutdown?)&quot;<br>
                elif [ $ret = 0 ]; then<br>
                                echo &quot;Apache is already running ($pidfile)&quot;<br>
                                rc_failed $ret<br>
                                rc_status -v1<br>
                                rc_exit<br>
                fi<br>
        fi<br>
<br>
        echo -n &quot;Starting httpd2 (${APACHE_MPM:-${apache_bin#*-}}) &quot;<br>
        cmdline=$(echo $apache_bin -f $httpd_conf $server_flags &quot;$@&quot;)<br>
        if eval $cmdline -t &gt; $logdir/rc$pname.out 2&gt;&amp;1 ; then<br>
                export -n ${!APACHE_*}<br>
                eval startproc -f -t ${APACHE_START_TIMEOUT:-2} $cmdline<br>
                ret=$?<br>
<br>
                if test -t 1 &amp;&amp; stty -a 2&gt;/dev/null | grep -q -- -echo\ ; then<br>
                        # this means that apache was still waiting for a passphrase to be entered<br>
                        stty echo 2&gt;/dev/null<br>
                        echo;echo<br>
                        echo &gt;&amp;2 An SSL passphrase has not been entered within<br>
${APACHE_START_TIMEOUT:-&lt;not set&gt;} seconds.<br>
                        echo &gt;&amp;2 To increase this timeout, adjust APACHE_START_TIMEOUT in<br>
$sysconfig_apache .<br>
                        # this surely means that apache won&#39;t start, despite it looked good<br>
to startproc<br>
                        killall $apache_bin<br>
                        echo &gt;&amp;2 &quot;Trying to start the server without SSL (-D NOSSL).&quot;<br>
                        $0 start &quot;$@&quot; -D NOSSL<br>
                        # rc_failed 1<br>
                        # rc_status -v1<br>
                        # rc_exit<br>
                else<br>
                        rc_failed $ret<br>
                        rc_status -v<br>
                fi<br>
        else<br>
                if [ &quot;$link&quot; = &quot;$base&quot; ] ; then<br>
                        cat $logdir/rc$pname.out<br>
                        echo &gt;&amp;2<br>
                        echo &gt;&amp;2 The command line was:<br>
                        echo &gt;&amp;2 $cmdline<br>
                        echo &gt;&amp;2<br>
                else<br>
                        echo -e -n &quot;\nsee $logdir/rc$pname.out for details\n&quot;;<br>
                fi<br>
                rc_failed 1<br>
                rc_status -v1<br>
        fi<br>
        ;;<br>
    stop)<br>
        echo -n &quot;Shutting down httpd2 &quot;<br>
        if [ ! -f $pidfile -a -f $pidfile.rpmsave ]; then mv<br>
$pidfile.rpmsave $pidfile; fi<br>
        if ! [ -f $pidfile ]; then<br>
                echo -n &quot;(not running)&quot;<br>
        else<br>
                pid=$(&lt;$pidfile)<br>
                kill -TERM $pid 2&gt;/dev/null<br>
                case $? in<br>
                    1)  echo -n &quot;(not running)&quot;;;<br>
                    0)  # wait until the processes are gone (the parent is the last one)<br>
                        echo -n &quot;(waiting for all children to terminate) &quot;<br>
                        for ((wait=0; wait&lt;120; wait++)); do<br>
                                if test -f $pidfile; then<br>
                                        usleep 500000<br>
                                        continue<br>
                                fi<br>
                                if ! test -f /proc/$pid/exe; then<br>
                                        break<br>
                                fi<br>
                                if test &quot;$(readlink /proc/$pid/exe 2&gt;/dev/null)&quot; = $apache_bin; then<br>
                                        usleep 500000<br>
                                else<br>
                                        break<br>
                                fi<br>
<br>
                        done<br>
                        ;;<br>
                esac<br>
        fi<br>
<br>
        rc_status -v<br>
        ;;<br>
    stop-graceful)<br>
        echo &quot;Shutting down httpd2 gracefully (SIGWINCH)&quot;<br>
        if ! [ -f $pidfile ]; then<br>
                echo -n &quot;(not running)&quot;<br>
        else<br>
                pid=$(&lt;$pidfile)<br>
                kill -WINCH $pid 2&gt;/dev/null<br>
                case $? in<br>
                    1)  echo -n &quot;(not running)&quot;;;<br>
                    0)  # wait until the pidfile is gone. The parent<br>
stays there, but closes the listen ports.<br>
                        echo -n &quot;(waiting for parent to close listen<br>
ports and remove pidfile) &quot;<br>
                        for ((wait=0; wait&lt;120; wait++)); do<br>
                                if test -f $pidfile; then<br>
                                        usleep 500000<br>
                                        continue<br>
                                else<br>
                                        break<br>
                                fi<br>
                        done<br>
                        ;;<br>
                esac<br>
        fi<br>
<br>
        rc_status -v<br>
        ;;<br>
    try-restart)<br>
        ## Do a restart only if the service was active before.<br>
        ## Note: try-restart is now part of LSB (as of 1.9).<br>
        ## RH has a similar command named condrestart.<br>
        $0 status<br>
        if test $? = 0; then<br>
                $0 restart<br>
        else<br>
                rc_reset        # Not running is not a failure.<br>
        fi<br>
        # Remember status and be quiet<br>
        rc_status<br>
        ;;<br>
    restart)<br>
        $0 configtest &quot;$@&quot; || { rc_failed $?; rc_exit; }<br>
<br>
        if $0 status &amp;&gt;/dev/null; then<br>
                $0 stop<br>
        fi<br>
        $0 start &quot;$@&quot;<br>
        # Remember status and be quiet<br>
        rc_status<br>
        ;;<br>
    restart-hup)<br>
        $0 configtest &quot;$@&quot; || { rc_failed $?; rc_exit; }<br>
<br>
        if $0 status &amp;&gt;/dev/null; then<br>
                echo -n &quot;Restarting httpd2 (SIGHUP)&quot;<br>
                kill -HUP $(&lt;$pidfile) || return=$rc_failed<br>
        else<br>
                $0 start &quot;$@&quot;<br>
        fi<br>
        # Remember status and be quiet<br>
        rc_status -v<br>
        ;;<br>
    restart-graceful)<br>
        $0 configtest &quot;$@&quot; || { rc_failed $?; rc_exit; }<br>
<br>
        if $0 status &amp;&gt;/dev/null; then<br>
                $0 stop-graceful &quot;$@&quot;<br>
                $0 start &quot;$@&quot;<br>
        else<br>
                $0 start &quot;$@&quot;<br>
        fi<br>
        # Remember status and be quiet<br>
        rc_status<br>
        ;;<br>
    reload|force-reload|graceful)<br>
        echo -n &quot;Reload httpd2 (graceful restart)&quot;<br>
        cmdline=$(echo $apache_bin -f $httpd_conf $server_flags &quot;$@&quot;)<br>
        if eval $cmdline -t &amp;&gt; $logdir/rc$pname.out; then<br>
                killproc -USR1 $apache_bin || return=$rc_failed<br>
                rc_status -v<br>
        else<br>
                if [ &quot;$link&quot; = &quot;$base&quot; ] ; then<br>
                        echo -e -n &quot;\n\n&quot;<br>
                        cat $logdir/rc$pname.out<br>
                        echo &gt;&amp;2<br>
                        echo &gt;&amp;2 The command line was:<br>
                        echo &gt;&amp;2 $cmdline<br>
                        echo &gt;&amp;2<br>
                else<br>
                        echo -e -n &quot;\nsee $logdir/rc$pname.out for details\n&quot;;<br>
                fi<br>
                rc_failed 6<br>
                rc_status -v1<br>
        fi<br>
        ;;<br>
    status)<br>
        if [ ! -f $pidfile -a -f $pidfile.rpmsave ]; then mv<br>
$pidfile.rpmsave $pidfile; fi<br>
        echo -n &quot;Checking for httpd2: &quot;<br>
        # we don&#39;t use checkproc here since it is confused when we exchange<br>
the binaries<br>
        if ! [ -f $pidfile ]; then<br>
                # not running<br>
                rc_failed 3<br>
        elif [ -s $pidfile -a -d /proc/$(&lt;$pidfile) ]; then<br>
                # running<br>
                :<br>
        else<br>
                # stale pid file<br>
                rc_failed 1<br>
                #rm -f $pidfile<br>
        fi<br>
        rc_status -v<br>
        ;;<br>
    probe)<br>
        ## Optional: Probe for the necessity of a reload,<br>
        ## give out the argument which is required for a reload.<br>
<br>
        for i in $httpd_conf \<br>
          $APACHE_CONF_INCLUDE_FILES \<br>
          $APACHE_CONF_INCLUDE_DIRS<br>
        do<br>
                if [ $i -nt $pidfile ]; then<br>
                        echo reload<br>
                        break<br>
                fi<br>
        done<br>
        ;;<br>
<br>
    conf*|test|syntax|check)<br>
        cmdline=$(echo $apache_bin -f $httpd_conf $server_flags &quot;$@&quot;)<br>
        eval $cmdline -t<br>
        rc_failed $?<br>
        rc_exit<br>
        ;;<br>
<br>
    extr*)<br>
        cmdline=$(echo $apache_bin -f $httpd_conf $server_flags &quot;$@&quot;)<br>
        out=$(su - nobody -c &quot;$cmdline&quot; 2&gt;&amp;1)<br>
        case $out in<br>
            *make_sock:\ could\ not\ bind\ to\ address*) echo Syntax: OK; rc_failed=0;;<br>
            *) echo Syntax: NOT OK:; echo $out; rc_failed=1;;<br>
        esac<br>
        rc_exit<br>
        ;;<br>
<br>
    server-status)<br>
        apache2ctl status<br>
        ;;<br>
<br>
    full-server-status|fullstatus)<br>
        apache2ctl fullstatus<br>
        ;;<br>
<br>
    *)<br>
    cat &gt;&amp;2 &lt;&lt;-EOF<br>
        Usage: $0 &lt;command&gt; &lt;server flags&gt;<br>
<br>
        where &lt;command&gt; is one of:<br>
                start              - start httpd<br>
                startssl           - start httpd with -DSSL<br>
                stop               - stop httpd (sending SIGTERM to parent)<br>
                try-restart        - stop httpd and if this succeeds (i.e. if<br>
                                     it was running before), start it again.<br>
<br>
                status             - check whether httpd is running<br>
<br>
                restart            - stop httpd if running; start httpd<br>
                restart-graceful   - stop httpd gracefully if running; start httpd<br>
                reload|graceful    - do a graceful restart by sending a SIGUSR1, or<br>
                                     start if not running<br>
                stop-graceful      - stop httpd (sending SIGWINCH to parent)<br>
<br>
                configtest         - do a configuration syntax test<br>
                extreme-configtest - try to run httpd as nobody (detects more errors<br>
                                     by actually loading the configuration, but cannot<br>
                                     read SSL certificates)<br>
                probe              - probe for the necessity of a reload, give<br>
                                     out the argument which is required for a reload.<br>
                                     (by comparing conf files with pidfile timestamp)<br>
<br>
                full-server-status - dump a full status screen; requires lynx or w3m<br>
                                     and mod_status enabled<br>
                server-status      - dump a short status screen; requires lynx or w3m<br>
                                     and mod_status enabled<br>
<br>
                help               - this screen<br>
<br>
        optional server flags are passed through to httpd.<br>
<br>
        EOF<br>
    exit 1<br>
esac<br>
<br>
<br>
# Inform the caller not only verbosely and set an exit status.<br>
rc_exit<br>
<br>
_______________________________________________<br>
Linux-il mailing list<br>
<a href="mailto:Linux-il@cs.huji.ac.il">Linux-il@cs.huji.ac.il</a><br>
<a href="http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il" target="_blank">http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il</a><br>
</blockquote></div><br></div></div>