Skip to main content

One Tomcat instance for two domains and two webapps



How can I configure Tomcat (in standalone mode, that is without Apache [*]) so that I can deploy it on one server and have it serve two different webapps, depending on the domain name requested?





I found a blog entry describing such a setup, but it's for Tomcat 5.5:







<Engine defaultHost="domain1.com" name="Catalina">

<Host name="domain1.com" appBase="/home/user1/domain1">

<Alias>www.domain1.com</Alias>

<Context path="" docBase="."/>

</Host>

<Host name="domain2.com" appBase="/home/user1/domain2">

<Alias>www.domain2.com</Alias>

<Context path="" docBase="."/>

</Host>







http://iam-rakesh.blogspot.com/2009/10/hosting-multiple-domains-in-tomcat.html





Also, as of now I've got one webapp, ROOT.war, inside .../tomcat/webapps/





How would that work once I'd have two "roots", one root webapp for domain1.com and one root webapp for domain2.com? Where would the .war needs to be located?


Comments

  1. The blog that you linked to basically shows how to do it. The one thing that you need to differently is to set the 'docBase' attribute differently for each host. The docBase is the location of war files for that host. With different docBases, you can have different root apps.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.