tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Frey <rainer.f...@inxmail.de>
Subject Re: How to serve .net and java websites on Windows 2008 with IIS7 and Tomcat
Date Wed, 02 Feb 2011 08:05:41 GMT
On Wednesday 02 February 2011 01:51:51 Jordan Michaels wrote:

Please don't top post.

> On 02/01/2011 04:38 PM, Conway Liu wrote:
> > It seems like the Tomcat service only serves applications from one
> > location ($CATALINA_HOME)

No. you can have
* webapps with a document path outside $CATALINA_HOME/$CATALINA_BASE
* (virtual) hosts with an appBase (base directory of all webapps of this host) 
outside $CATALINA_HOME/$CATALINA_BASE
* multiple tomcat instances with their webapps,configuration,logs ... in their 
own $CATALINA_BASE (and have their appBase/docPath outside this one 
$CATALINA_BASE)

> > Instead, we need to run them as
> > www.website1.com
> > www.website2.com
> > which is why we have created multiple IP addresses on the server.
> > 
> > And the jsp websites will sit in seperate physical folders on the server,
> > for example:
> > C:\website1\
> > C:\website2\

> A simple answer to your question is to create additional <Host> entries
> to your Tomcat server.xml file. 

That's the way to go.

> While I know that there are some on this
> list who disagree with this method, I personally find that configuring
> hosts and contexts in the server.xml file very simple as it makes adding
> new hosts to Tomcat similar to adding new hosts in Apache.

Hosts are usually configured in server.xml (unless you use some kind  of 
dynamic/programmatic configuration).

With contexts, it's not  "some on this list who disagree", it is "Tomcat 
developers discourage this method in the official documentation". It still 
works as of Tomcat 6 and 7 though.

>          <Host name="ourserver.com" appBase="webapps"
>               unpackWARs="true" autoDeploy="true"
>               xmlValidation="false" xmlNamespaceAware="false">
>               <Context path="" docBase="C:\website1\" />
>               <Alias>www.ourserver.com</Alias>
>          </Host>

You can achieve the same with:
<tomcat>/conf/server.xml:
          <Host name="example.com" appBase="example.com-webapps"
               unpackWARs="true" autoDeploy="true"
               xmlValidation="false" xmlNamespaceAware="false">
               <Alias>www.example.com</Alias>
          </Host>

<tomcat>/conf/Catalina/example.com/ROOT.xml:
<Context docBase="C:\website1\" />

Notes:
* appBase must be different for every host. Better take care of that even if 
you mean to deploy outside the appBase. appBase can also refer to a  path 
outside the tomcat directory structure.
* if you need/want the Tomcat manager app, you need to deploy it in each host
* if you have no specific reasons for your directory structure (like existing 
backup or fileserver infrastructure), you can as well deploy into appBase, 
with your webbapp in a directory named <appBase>/ROOT or in a .war file named 
<appBase>/ROOT.war and discard above mentioned ROOT.xml. It will more closely 
match what other tomcat users/admins are used to and function the same way.

> And Tomcat will now know how to resolve each domain to it's own
> directory rather then inside the ROOT webapp.
> 
> There are other ways to configure contexts, which I'm sure folks will
> post about subsequently, but I've found this works quite well and
> whether it's the "proper" way to do it or not, it will solve your problem.

The/one major drawback is: you need to restart Tomcat completely for any 
webapp context that's added/deleted/reconfigured.
I also don't see that much of an advantage compared to context.xml config 
files.

> > I think there's something to do with $CATALINA_BASE that I need to
> > configure, but I don't know how.

You need to do that only if you want to run a separate tomcat instance for 
each webapp. Each instance has its own Tomcat configuration, and its own JVM. 
Use it only if you need/want that.

> > Regards and thanks
> > Conway
> -Jordan

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message