开发者

Deploy several webapps configured as Root in a same instance of Tomcat

开发者 https://www.devze.com 2023-03-09 21:03 出处:网络
I have about 6 or 7 webapps which are configured to be deployed as the root app on Tomcat (6). So, each app can be later accessed by http://host:8080/

I have about 6 or 7 webapps which are configured to be deployed as the root app on Tomcat (6). So, each app can be later accessed by http://host:8080/

I have to deploy these webapps in one computer for a QA environment. The team commented about using one instance of Tomcat开发者_JS百科, and deploy each webapp on a different port, so they would still be deployed as the root application.

Any suggestions as to how to do this and what the best approach is?


You need to look into virtual hosts.

A regular host lookup of the root context is something like http://www.mymachine.com:8080/, when you want to put two applications at that same context, Tomcat can't do it because it doesn't know which application should respond to such a lookup. Normally Tomcat resolves these conflicts by promoting the placement of different apps in an "application" path, like so

http://www.mymachine.com:8080/app1 (maps to) "Application 1"
http://www.mymachine.com:8080/app2 (maps to) "Application 2"

However with virtual hosts, one configures a single web server to respond to multiple host name lookups. With such a configuration, the hostname can then be used as the differentiator.

http://app1.mymachine.com:8080/(root) (maps to) "Application 1"
http://app2.mymachine.com:8080/(root) (maps to) "Application 2"

Note that such a configuration requires that you do the extra work of making sure that DNS knows both hostnames and maps them both back to the same Tomcat server. Then Tomcat (or Apache if running an Apache server in front of your Tomcat server) must be configured to map the request by it's hostname and application path to a webapp instead of just mapping by the application path to a webapp.

Here is the documentation on how to do this in Tomcat 6.0. Note that this doesn't apply to the necessary networking work you'll need to do to get both hostnames to resolve to the same machine. Good luck!


I don't think you can get away with using only one instance.

If you need each application to run as the root app, then you will have to have several tomcat instances running on different ports.

To deploy as the root application, simply name your application ROOT.war and place it in the webapps directory of Tomcat.

As to whether or not this is the right approach, I would have to disagree. You will more than likely run into Port in Use hell. It will be very difficult and silly to have to manage all the different ports utilized by tomcat.

0

精彩评论

暂无评论...
验证码 换一张
取 消