在同一台服务器上启动多个 Tomcat 服务,需要修改 conf/server.xml文件里的三个部分,如下:
1.修改Http访问端口(默认为8080端口)
<Connector port="8083" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
2.修改Shutdown端口(默认8005端口)
<Server port="8006" shutdown="SHUTDOWN">
3.修改8009端口
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
以上重新设定的端口需要在 Linux 服务器上确认开启,否则无法正确访问 Tomcat
----------------------- server.xml 完整事例 ------------------
<?xml version='1.0' encoding='utf-8'?> <Server port="8006" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <Listener className="org.apache.catalina.core.JasperListener" /> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <GlobalNamingResources> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <Service name="Catalina">
<!-- tomcat 连接池的配置 --> <Excutor name="tomcatThreadPool" namePrefix="catalina-exec" maxThread="500" minSpareThreads="20" maxIdleTime="60000" /> <Connector executor="tomcatThreadPool" port="8083" protocol="HTTP/1.1" connectionTimeout="60000" keepAliveTimeout="15000" maxKeepAliveRequests="1" acceptCount="100" enableLookups="false" disableUploadTimeout="true" redirectPort="8443" /> <!-- 出于安全的考虑,下面这条配置可以注销, 可以防止 ping 域名获得 IP地址 --> <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> <Context path="" docBase="/usr/local/apache-tomcat-all-7.0.29/apache-tomcat-cms/webapps/qs_api" debug="0" reloadable="true" /> </Host> </Engine> </Service> </Server>