1.一个Tomcat下配置多个端口号,这里是针对一个应用服务而言,只需在Service下配置多个<Connector>。如下:
<Server port="8005" shutdown="SHUTDOWN" debug="0"> <Service name="Catalina">
<Connector
port="8089" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" URIEncoding="utf-8"
disableUploadTimeout="true" />
<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
<Connector port="8099" protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" URIEncoding="utf-8"
disableUploadTimeout="true" />
<Engine name="Catalina" defaultHost="localhost" debug="0">
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
在这个应用里,可以用8089端口号访问服务,也可以用8099端口号来访问服务;
(注:这里的Host中没有配置context内容,是通过D:\Java\Tomcat 5.0\conf\Catalina\localhost下的一个*.xml指定的)这里的*.xml的内容如下:
<Context displayName="dmis" docBase="D:/IBM/workspace/dmisArea/WebRoot" path="/dmis" privileged="true" workDir="work\Catalina\localhost\dmis">
</Context>
2.在一个Tomcat下配置多个服务,用不同的端口号。
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Catalina">
<Connector
port="8089" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" URIEncoding="utf-8"
disableUploadTimeout="true" />
<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
<Connector port="8099" protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" URIEncoding="utf-8"
disableUploadTimeout="true" />
<Engine name="Catalina" defaultHost="localhost" debug="0">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
</Host>
</Engine>
</Service><Service name="webportal">
<Connector port="8090" protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000" URIEncoding="utf-8"
disableUploadTimeout="true" />
<Engine name="myengine" defaultHost="myhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="myhost" appBase="webapplrm"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context displayName="pow2org" docBase="D:\IBM\workspace\pow2org\WebRoot" path="/pow2org" privileged="true" workDir="work\myengine\localhost\pow3org">
</Context>
</Host>
</Engine>
</Service>
</Server>