1、docBase:设置成这种样式后,js修改后无需重新发布
<Context docBase="D:\svn\scim\trunk\scim\WebContent" path="/" reloadable="false"/>
2、maxHttpHeaderSize:request请求参数最大
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" maxHttpHeaderSize="131072" maxPostSize="4194304"/>
3、修改JSESSIONID的名字,防止多个tomcat发布一个web时,帐号互踢
<Context sessionCookieName="JSP_SessionId">//session、cookie
4、tomcat的几个端口:port="8080" http访问端口、redirectPort="8443" https访问端口、port="8005" 远程停服务端口、port8009AJP端口,APACHE能过AJP协议访问TOMCAT的8009端口
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="60000" redirectPort="8443" disableUploadTimeout="false" executor="tomcatThreadPool" URIEncoding="UTF-8"/> <Server port="8005" shutdown="SHUTDOWN">
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
5、一个tomcat部署多个项目:复制多个<service></service>节点,修改8080端口、注释8009端口、修改appBase
<!-- the first service--> <Service name="Catalina"> <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- 注释的地方--> <!-- <Connector port="8009" 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" /> </Host> </Engine> </Service>
<!-- the second service--> <Service name="Catalina"> <!-- 修改的地方--> <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- 注释的地方--> <!--<Connector port="8009" 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> <!-- 修改的地方 appBase:第二个项目放置的位置--> <Host name="localhost" appBase="webapps1" 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" /> </Host> </Engine> </Service>
6、一个环境中部署多个tomcat//增加环境变量CATALINA_HOME2,值为新的tomcat的地址;增加环境变量CATALINA_BASE2,值为新的tomcat的地址。 //修改新的tomcat中的startup.bat、shutdown.bat,把其中的CATALINA_HOME改为CATALINA_HOME2。 //修改新的tomcat中的catalina.bat,把其中的CATALINA_HOME改为CATALINA_HOME2,CATALINA_BASE改为CATALINA_BASE2。 //修改conf/server.xml文件 <Server port="8005" shutdown="SHUTDOWN">把端口改为没有是使用的端口。 <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" /> 把端口改为没有是使用的端口。 <Connector port="8009"enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /> 把端口改为没有是使用的端口。
7、一个完整的tomcat server.xml配置文件。
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN"> <Service name="Catalina"> <Connector connectionTimeout="20000" maxHttpHeaderSize="131072" maxPostSize="4194304" port="8080" protocol="HTTP/1.1" redirectPort="8443"/> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/> <Engine defaultHost="localhost" name="Catalina"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/> <Context docBase="D:\svn\scim\trunk\scim\scim_web\WebContent" path="/" reloadable="false"/> </Host> </Engine> </Service>
</Server>
ps:5/6参考:http://blog.csdn.net/kangguowei/article/details/53037563