tomcat多端口,多web程序的一点学习经验

tomcat 多端口,多 web 程序的一点学习经验

1.         直接从 tomcat 根目录开始,只需要修改 conf 下的 server.xml 文件, <Server /> 节点下是 <Service name="liuch">name 是关键,起不同的名称配置两个节点,这样才能实现多端口

<Server port="8005" shutdown="SHUTDOWN" debug="0">

<Service name="liuch">

<Connector className="org.apache.catalina.connector.http.HttpConnector"

               port="8080" minProcessors="5" maxProcessors="75"

               enableLookups="true" redirectPort="8443"

               acceptCount="10" debug="0" connectionTimeout="60000"/>

<Engine name="Standalone" defaultHost="cpgsj" debug="0">

<Host name=" cpgsj " debug="0" appBase="C:/oa/ghjOAlc" unpackWARs="true">

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

</Host>

</Engine>

  </Service>

<Service name="zhangjy">

<Connector className="org.apache.catalina.connector.http.HttpConnector"

               port="8081" minProcessors="5" maxProcessors="75"

               enableLookups="true" redirectPort="8443"

               acceptCount="10" debug="0" connectionTimeout="60000"/>

<Engine name="Standalone" defaultHost=" localhost " debug="0">

<Host name="localhost" debug="0" appBase="C:/oa/ghjOAlc" unpackWARs="true">

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

</Host>

</Engine>

</Service>

</Service>

Appbase 是程序位置, docBase 设置为 . 就可以了, Engine 中有个属性 defaultHost 设置为节点下 host 节点的 name ,注意 host name 的名称不能相同通过 http://localhost 8080 就可以访问第一个程序了;第二个程序的访问地址 http:// localhost 8081

访问程序的默认页面为 index.jsp 时有效

2.         同一端口设置多个程序

<Server port="8005" shutdown="SHUTDOWN" debug="0">

<Service name="liuch">

<Connector className="org.apache.catalina.connector.http.HttpConnector"

               port="8080" minProcessors="5" maxProcessors="75"

               enableLookups="true" redirectPort="8443"

               acceptCount="10" debug="0" connectionTimeout="60000"/>

<Host name="lc" debug="0" appBase="C:/oa/ghjOAlc" unpackWARs="true">

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

</Host>

<Host name="tj" debug="0" appBase="C:/oa/ghjOAja" unpackWARs="true">

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

</Host>

</Service>

</Service>

Service 节点下设置两个 Host name 不能相同

E:/Windows/System32/drivers/etc/hosts 文件中添加节点

127.0.0.1       lc

127.0.0.1       tj

就可以分别通过访问 http://lc 8080 http://tj 8080 访问你的程序了

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值