部署多个项目到tomcat

18 篇文章 0 订阅
6 篇文章 0 订阅
If you want Tomcat to listen to multiple ports, you need to setup a connector for each port. To get each port mapped to a different application, you need need to wrap each connector in a service and create a host with it's own appBase.

Example of service definition in server.xml:

<Service name="foo">
<Connector port="80" protocol="org.apache.coyote.http11.Http11NioProtocol" />
<Engine name="Catalina80" defaultHost="localhost">
<Host name="localhost" appBase="foo" unpackWARs="true" autoDeploy="true" />
</Engine>
</Service>

<Service name="bar">
<Connector port="81" protocol="org.apache.coyote.http11.Http11NioProtocol" />
<Engine name="Catalina81" defaultHost="localhost">
<Host name="localhost" appBase="bar" unpackWARs="true" autoDeploy="true" />
</Engine>
</Service>
Instead of dropping the war files in the webapps directory, you need to create the directory foo for port 80 and bar for port 81. Name both war files ROOT.war and drop them in their own base directory. You can of course have multiple apps in each directory if you need.

The directory defined in appBase is relative to the tomcat directory. By using an absolute path, it could be anywhere on your system. From the documentation:

appBase

The Application Base directory for this virtual host. This is the pathname of a directory that may contain web applications to be deployed on this virtual host. You may specify an absolute pathname, or a pathname that is relative to the $CATALINA_BASE directory. [...] If not specified, the default of webapps will be used.
Another option is to keep the default tomcat configuration and use another http server (apache, nginx, lighttpd,...) to map a port to the internal path of a tomcat application.

The root application won't receive requests that match other applications, e.g. /foo/example will go to foo.war, /example/example will go to ROOT.war.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值