【问题标题】:Tomcat Multiple Localhost Instances [closed]Tomcat多个本地主机实例[关闭]
【发布时间】:2012-04-24 14:56:39
【问题描述】:

将 Tomcat 配置为拥有两个 localhost 实例的最聪明的方法是什么?

请注意,我没有系统管理员权限,因此无权访问 /etc/hosts 文件。我希望能够执行以下操作,但无法修改我的 /etc/hosts 文件: http://juststuffreally.blogspot.com/2007/03/enabling-multiple-localhost-sites-in.html

我想要这样的东西,以便我的 localhost 实例如下所示:

keith.localhost.com joe.localhost.com

...但我无法修改我的 /etc/hosts 文件 =-(

我发现的另一个资源是这个,但这给出了多个外部域的说明——我需要多个 localhost 实例: http://iam-rakesh.blogspot.com/2009/10/hosting-multiple-domains-in-tomcat.html

有什么想法吗?

感谢您的帮助。

【问题讨论】:

    标签: apache tomcat localhost instances


    【解决方案1】:

    您可以在多个端口上运行多个 tomcat 实例。每个实例都需要一个唯一的server.xml,并且每个实例都需要在相应的<Server><Connector> 元素中定义不同的端口。

    一切都设置好后,您可以在连接到实例时指定一个显式端口,例如:

    - http://localhost:8080/
    - http://localhost:8081/
    

    This document 更详细地介绍了该过程。

    【讨论】:

    • 谢谢!这现在工作得很好。以下链接也非常有帮助:
    • 我很高兴它有帮助!看起来 SO 可能已经吃掉了你的链接。
    • 我编写了一个基于 Java 的便携式实用程序,用于自动执行上述创建多个实例的步骤:javaexperience.com/run-multiple-tomcat-instances
    • 有没有办法检测哪些端口是空闲的并且可以被新实例使用?或者有没有办法让 Tomcat 随机选择一个空闲端口并以某种方式告诉用户?
    猜你喜欢
    • 2011-03-09
    • 2012-01-10
    • 1970-01-01
    • 2020-10-09
    • 2011-11-13
    • 2013-04-28
    • 2012-02-16
    • 2015-02-05
    • 2015-07-31
    相关资源
    最近更新 更多