You may find that the default host loads all of the
web applications.

In order to solve this, make sure that each of the
contexts are not some subdirectory of another context.

<Host name="localhost" appBase="vhosts/local" />
<Host name="foo.mydomain.com" appBase="vhosts/foo" />
<Host name="bar.mydomain.com" appBase="vhosts/bar" />
<Host name="eggs.mydomain.com" appBase="vhosts/eggs"
/>

You can use an absolute path to place this structure
outside of your Tomcat installation.  For large
structures I think this is nice, because then you can
upgrade Tomcat without disturbing your applications. 
Cutover would involve installing a parallel Tomcat,
modifying server.xml. shutting down the old version,
and starting up the new version.  If the new version
failed, recovery is just shutting down the new version
and starting up the old version.

If you want a one-stop place for all of your web
applications, please ignore this comment.

For a root context, I usually set up an
application.xml file in conf/Catalina/<hostname>/ with
the appropriate path="" in the Context element, or a
context.xml file in the web application's META-INF
directory with the same context information.

Once you separate each of the virtual hosts so that
subdirectories don't overlap, I think you will find
that multiple manager applications work.  The manager
application will then be specific to the virtual host,
and you'll have to access that manager application by
going to the specific virtual host (ie,
http://<hostname>:8080/manager/html)

HTH

/mde/
. . . . . just my two cents

--- "Gormley, Josh" <[EMAIL PROTECTED]> wrote:

> With the help of several people on this list, I've
> been able to get my
> server configured [mostly] the way I wanted it
> configured.  Here's my
> solution, hopefully it will be helpful to others
> 
> Goals:
>   * One instance of Tomcat running behind Apache
>   * Multiple VirtualHosts, each pointing to its own
> Tomcat webapp
>   * The ability to hot-deploy an app without
> affecting the other apps
>   * Minimal or no modifications required to
> server.xml for additional
>     hosts
>   * A solution that is maintainable and is not a
> hack
> 
> Solution:
>   * Apache with mod_jk
>   * Each domain has a .conf file at
> /etc/httpd/conf.d/vhosts
>     * The conf file routes .do and .jsp files to
> tomcat using mod_jk
>         JkMount /*.do router
>         JkMount /*.jsp router
>     * The VirtualHost declaration has the
> DocumentRoot set to the path
>       of the webapp
>   * Tomcat's server.xml file has a host declaration
> for each webapp 
>     and a declaration for localhost (though that is
> not necessary)
>         <Host name="localhost" appBase="webapps" />
>         <Host name="foo.mydomain.com"
> appBase="webapps/foo" />
>         <Host name="bar.mydomain.com"
> appBase="webapps/bar" />
>         <Host name="eggs.mydomain.com"
> appBase="webapps/eggs" />
>   * Deploy a war file named ROOT.war to the correct
> appBase for each
>     application.  This file must be named ROOT.war
>   * GOTCHA: I tried to also include the manager
> webapp for each of the 
>     hosts by adding the manager.xml file to 
>     $CATALINA_HOME/conf/Catalina/foo.mydomain.com/
> as described here
>    
>
http://webtuitive.com/samples/virtual-hosting-howto.jsp
>     but by having a context defined in this
> location, I was not able 
>     to deploy my applications using Automatic
> Application Deployment
>     as defined in the Tomcat docs.  I'm not sure why
> this doesn't work
>     but by removing the manager.xml file, I am able
> to hot-deploy my
>     apps.
> 
> This is working well for me, and that in itself
> makes me happy.  The 
> only things I'd like to improve upon are:
>   * Not having to modify server.xml directly. 
> According to the Tomcat
>     docs, you shouldn't modify this file.  I'm not
> sure how to avoid 
>     this.
>   * Being able to include the manager app for each
> host that I define.
> I
>     was using ant's tomcat tasks to tie into the
> manager for deploying
>     my apps, but now I have to scp the war file into
> the directory.
>     This isn't the worst thing that could happen,
> but it seems like 
>     there is a solution out there for this.
> 
> Anyway, thanks to everybody who helped out on this.
> 
> Josh Gormley
> 
> 
> 
> -----Original Message-----
> From: Mikolaj Rydzewski [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 28, 2006 9:34 AM
> To: Tomcat Users List
> Subject: Re: Virtual Hosts
> 
> Gormley, Josh wrote:
> > As a side question, is this possible to do without
> modifying the
> > server.xml file every time I want to add a new
> host?  I've read that
> > it's bad practice to modify the server.xml file
> much like it's bad
> > practice to modify the httpd.conf file in Apache. 
> In Apache, I have a
> > vhost directory with .conf files for each host --
> is there a similar
> > method to do this with Tomcat?
> >   
> There is a host-manager webapp which comes with
> Tomcat to allow adding 
> vhosts on the fly (I haven't used it, however). You
> will need user with 
> admin role in tomcat-users.xml to access it.
> 
> -- 
> Mikolaj Rydzewski <[EMAIL PROTECTED]>
> 
> 
> 
>
---------------------------------------------------------------------
> To start a new topic, e-mail:
> users@tomcat.apache.org
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to