如何在不同端口后面的单个 Tomcat 实例上运行不同的应用程序?
目前,我有 2 个 Web 应用程序 app1 和 app2 在 Tomcat 6 上运行:
- app1 在 http://localhost:8080/app1 上
- http://localhost:8080/app2 上的 app2
我想配置 Tomcat,以便它们在单独的根上下文中运行端口:
需要做什么?
Currently I have 2 web applications app1 and app2 running on Tomcat 6:
- app1 on http://localhost:8080/app1
- app2 on http://localhost:8080/app2
I want to configure Tomcat so that they run in root context behind separate ports:
- app1 on http://localhost:8081
- app2 on http://localhost:8082
What needs to be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我认为你可以在 server.xml 文件中配置它并放置 2 个服务:
I think you can configure that in you server.xml file and put 2 services :
添加连接器的另一个示例:
取自: http://www.coderanch .com/t/84172/Tomcat/listen-multiple-ports
我建议阅读整个线程,因为它讨论了此配置的性能影响,以及可能的竞争条件。
Another example of adding connectors:
Taken from: http://www.coderanch.com/t/84172/Tomcat/listen-multiple-ports
I recommend reading the whole thread, as it talks about performance hits with this configuration, and also possible race conditions.
除了运行两个 Tomcat 实例并使用 ROOT 应用程序(已经说过,这是一个有点糟糕且无效的解决方案)之外,您还可以通过使用 Apache + Tomcat 来实现它。配置 apache 监听两个端口并通过 IP:Port 转发到不同的 Tomcat 应用程序。但您需要为 Tomcat 使用不同的端口!
Apache 配置
或
Besides running two Tomcat instances and using ROOT application (that has already been said and is a bit poor and ineffective solution) you can achieve it by using Apache + Tomcat. Configuring apache to listen to both ports and forward by IP:Port to different Tomcat applications. But you need a different port for Tomcat!
Apache configuration
or
使用两个不同的 Tomcat 实例。
编辑:
或者按照此问题的答案中的说明配置Tomcat: Tomcat 配置帮助:多个端口无响应
Use two different Tomcat instances.
EDIT:
Or configure Tomcat as explained in the answer of this question: Tomcat configuration help: multiple ports not responding
Tomcat 在指定的端口上运行:
正如 JB Nizet 所写,设置两个不同的 tomcat 实例,并相应地配置端口值 server.xml。
$CATALINA_HOME/tomcat-8081/conf/server.xml
:$CATALINA_HOME/tomcat-8082/conf/server.xml
:Tomcat runs on the ports specified in:
As JB Nizet wrote, setup two different instances of tomcat, and configure the port value server.xml appropriately.
$CATALINA_HOME/tomcat-8081/conf/server.xml
:$CATALINA_HOME/tomcat-8082/conf/server.xml
: