您的位置:首页 > 运维架构 > Tomcat

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

2009-06-04 19:15 239 查看

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
访问你的程序了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: