Linux Archive

Linux Archive (
-   Ubuntu Server Development (
-   -   apache2 two instances (Ubuntu/Debian) (

Keith Farrar 08-20-2010 11:56 PM

apache2 two instances (Ubuntu/Debian)
On Fri, 2010-08-20 at 07:10 -0700, Kaushal Shriyan wrote:


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



The Phusion Passenger module (mod_rails) previously conflicted with mod_rewrite, so I

used the following hack to create a separate Apache instance. Now that mod_rails and

mod_rewrite play nicely, I no longer need this hack, but it worked on a production Hardy

web server for a year.

I use an 'includes' directory to store common configuration chunks imported on multiple

virtual hosts (e.g specific authentication / authorization directives included within a <File>

or <Location> block).

The Ruby on Rails engine, Phusion Passenger (a.k.a. mod_rails) conflicts with the

standard modules mod_alias and mod_rewrite. So I cloned the* Apache configuration

files and modules into a separate directory tree, and the system now runs two

parallel daemons running on troy, using these configuration directories:

*** /etc/apache2/

*** /etc/apache2_modrails/

Pretty much everything that was called 'apache2*' in the standard configuration

(init.d scripts, /usr/sbin/ binaries) has a new copy or symlink to support the

parallel configuration. I used symlinks (or variables set in configuration files)

where possible, to avoid version drift when we patch the system. A global

substitution of "s/apache2/apache2_modrails/g" mostly worked for the

/etc/init.d/apache2_modrails script and the /usr/sbin/apache2_modrailsctl

script, but I needed to update some default settings within each script.

New directories:











New files:

*** /etc/apache2_modrails/apache2_modrails.conf

*** /etc/default/apache2_modrails

*** /etc/init.d/apache2_modrails

*** /usr/sbin/apache2_modrailsctl

*** /var/log/apache2/access-modrails_log

*** /var/log/apache2/error-modrails_log

*** /var/run/

New symlinks:

*** /usr/sbin/apache2_modrails -> /usr/sbin/apache2

*** /etc/rc0.d/K09apache2_modrails -> ../init.d/apache2_modrails

*** /etc/rc1.d/K09apache2_modrails -> ../init.d/apache2_modrails

*** /etc/rc2.d/S91apache2_modrails -> ../init.d/apache2_modrails

*** /etc/rc3.d/S91apache2_modrails -> ../init.d/apache2_modrails

*** /etc/rc4.d/S91apache2_modrails -> ../init.d/apache2_modrails

*** /etc/rc5.d/S91apache2_modrails -> ../init.d/apache2_modrails

*** /etc/rc6.d/K09apache2_modrails -> ../init.d/apache2_modrails

Configuration cloning hack, copy / symlink the files into the new skeleton directory tree.

cp -p /etc/apache2/* /etc/apache2_modrails/

First option avoids breakage if modules change path names in the standard location,

since the configuration files under this hack won't be updated by dpkg.

ln -s* /etc/apache2/mods-available/* /etc/apache2_modrails/mods-available/

Less fragile option - share the modules-available between the instances

rmdir /etc/apache2_modrails/mods-available

ln -s* /etc/apache2/mods-available /etc/apache2_modrails/

Add a localhost binding port for mod_rails Apache status in ports.conf and

/etc/default/apache2_modrails (the apache2ctl and apache2_modrailsctl scripts

call the lynx command line browser to dump output from the status port).

Apache status binding in /etc/apache2_modrails/ports.conf :

Listen localhost:81

Changes in /etc/default/apache2_modrails




ubuntu-server mailing list
More info:

All times are GMT. The time now is 11:30 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.