<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.28.3">
</HEAD>
<BODY>
On Fri, 2010-08-20 at 07:10 -0700, Kaushal Shriyan wrote: 
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hi

Can someone please guide me to setup two instances of apache2 along
with start/stop init.d script for both the instances.

Thanks

Kaushal

</PRE>
</BLOCKQUOTE>
<BR>
The Phusion Passenger module (mod_rails) previously conflicted with mod_rewrite, so I <BR>
used the following hack to create a separate Apache instance. Now that mod_rails and<BR>
mod_rewrite play nicely, I no longer need this hack, but it worked on a production Hardy<BR>
web server for a year.<BR>
<BR>
I use an 'includes' directory to store common configuration chunks imported on multiple<BR>
virtual hosts (e.g specific authentication / authorization directives included within a <File><BR>
or <Location> block). <BR>
<BR>
<BLOCKQUOTE>
    The Ruby on Rails engine, Phusion Passenger (a.k.a. mod_rails) conflicts with the<BR>
    standard modules mod_alias and mod_rewrite. So I cloned the  Apache configuration<BR>
    files and modules into a separate directory tree, and the system now runs two<BR>
    parallel daemons running on troy, using these configuration directories:<BR>
        /etc/apache2/<BR>
        /etc/apache2_modrails/<BR>
    <BR>
    Pretty much everything that was called 'apache2*' in the standard configuration<BR>
    (init.d scripts, /usr/sbin/ binaries) has a new copy or symlink to support the<BR>
    parallel configuration. I used symlinks (or variables set in configuration files)<BR>
    where possible, to avoid version drift when we patch the system. A global<BR>
    substitution of "s/apache2/apache2_modrails/g" mostly worked for the <BR>
    /etc/init.d/apache2_modrails script and the /usr/sbin/apache2_modrailsctl<BR>
    script, but I needed to update some default settings within each script.<BR>
    <BR>
    New directories:<BR>
    <BLOCKQUOTE>
        /etc/apache2_modrails/<BR>
        /etc/apache2_modrails/conf.d/<BR>
        /etc/apache2_modrails/includes/<BR>
        /etc/apache2_modrails/mods-available/<BR>
        /etc/apache2_modrails/mods-enabled/<BR>
        /etc/apache2_modrails/sites-available/<BR>
        /etc/apache2_modrails/sites-enabled/<BR>
        /var/cache/apache2_modrails/mod_disk_cache/<BR>
        /var/lock/apache2_modrails/<BR>
        /var/run/apache2_modrails/<BR>
    </BLOCKQUOTE>
    <BR>
    New files:<BR>
    <BLOCKQUOTE>
            /etc/apache2_modrails/apache2_modrails.conf<BR>
            /etc/default/apache2_modrails<BR>
            /etc/init.d/apache2_modrails<BR>
            /usr/sbin/apache2_modrailsctl<BR>
            /var/log/apache2/access-modrails_log<BR>
            /var/log/apache2/error-modrails_log<BR>
            /var/run/apache2_modrails.pid<BR>
    </BLOCKQUOTE>
    <BR>
    New symlinks:<BR>
    <BLOCKQUOTE>
            /usr/sbin/apache2_modrails -> /usr/sbin/apache2<BR>
            /etc/rc0.d/K09apache2_modrails -> ../init.d/apache2_modrails<BR>
            /etc/rc1.d/K09apache2_modrails -> ../init.d/apache2_modrails<BR>
            /etc/rc2.d/S91apache2_modrails -> ../init.d/apache2_modrails<BR>
            /etc/rc3.d/S91apache2_modrails -> ../init.d/apache2_modrails<BR>
            /etc/rc4.d/S91apache2_modrails -> ../init.d/apache2_modrails<BR>
            /etc/rc5.d/S91apache2_modrails -> ../init.d/apache2_modrails<BR>
            /etc/rc6.d/K09apache2_modrails -> ../init.d/apache2_modrails<BR>
    </BLOCKQUOTE>
    <BR>
    Configuration cloning hack, copy / symlink the files into the new skeleton directory tree.<BR>
    <BLOCKQUOTE>
        cp -p /etc/apache2/* /etc/apache2_modrails/<BR>
    </BLOCKQUOTE>
    First option avoids breakage if modules change path names in the standard location,<BR>
    since the configuration files under this hack won't be updated by dpkg.<BR>
    <BLOCKQUOTE>
        ln -s  /etc/apache2/mods-available/* /etc/apache2_modrails/mods-available/<BR>
    </BLOCKQUOTE>
    Less fragile option - share the modules-available between the instances<BR>
    <BLOCKQUOTE>
        rmdir /etc/apache2_modrails/mods-available<BR>
        ln -s  /etc/apache2/mods-available /etc/apache2_modrails/<BR>
    </BLOCKQUOTE>
    <BR>
    Add a localhost binding port for mod_rails Apache status in ports.conf and <BR>
    /etc/default/apache2_modrails (the apache2ctl and apache2_modrailsctl scripts <BR>
    call the lynx command line browser to dump output from the status port).<BR>
    <BR>
    Apache status binding in /etc/apache2_modrails/ports.conf :<BR>
    <BLOCKQUOTE>
        Listen localhost:81<BR>
    </BLOCKQUOTE>
    <BR>
    Changes in /etc/default/apache2_modrails<BR>
    <BLOCKQUOTE>
        APACHE_HTTPD=/usr/sbin/apache2_modrails<BR>
        APACHE_STATUSURL=<A HREF="http://localhost:81/server-status">http://localhost:81/server-status</A><BR>
        HTCACHECLEAN_PATH=/var/cache/apache2_modrails/mod_disk_cache<BR>
    </BLOCKQUOTE>
    <BR>
</BLOCKQUOTE>
<BR>
<BR>
<BR>
</BODY>
</HTML>