Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu Server Development (http://www.linux-archive.org/ubuntu-server-development/)
-   -   apache2 two instances (Ubuntu/Debian) (http://www.linux-archive.org/ubuntu-server-development/415986-apache2-two-instances-ubuntu-debian.html)

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:


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





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:


/etc/apache2_modrails/

/etc/apache2_modrails/conf.d/

/etc/apache2_modrails/includes/

/etc/apache2_modrails/mods-available/

/etc/apache2_modrails/mods-enabled/

/etc/apache2_modrails/sites-available/

/etc/apache2_modrails/sites-enabled/

/var/cache/apache2_modrails/mod_disk_cache/

/var/lock/apache2_modrails/

/var/run/apache2_modrails/




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/apache2_modrails.pid




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


APACHE_HTTPD=/usr/sbin/apache2_modrails

APACHE_STATUSURL=http://localhost:81/server-status

HTCACHECLEAN_PATH=/var/cache/apache2_modrails/mod_disk_cache













--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam


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

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