今天下载了apache-tomcat-6.0.29,替换原有的Tomcat5.5,随手记录笔记如下:

一、安装:
   http://tomcat.apache.org下载windows32版,解压更名后,D:\Tomcat。

二、开发配置:
1、启动eclipse,菜单windows\perferences,MyEclipse\Application Server,Tomcat5设置为Disable,Tomcat6设置为Enable。
2、Tomcat Home Directory按Brow按钮,设置为D:\tomcat,后面Base和Temp两项跟着自动变更了。

三、运行日志:
在控制台显示的异常在D:\tomcat\bin\log.dbLog.log
其中并未显示正常输出信息,若不满意,让Windows下的Tomcat将控制台信息记录到日志 :  
在Linux系统中,Tomcat 启动后默认将很多信息都写入到catalina.out 文件中,我们可以通过tail  -f  catalina.out 来跟踪Tomcat 和相关应用运行的情况。 在windows下,我们使用startup.bat启动Tomcat以后,会发现catalina日志与Linux记录的内容有很大区别,大多信息只输出到屏幕而没有记录到catalina.out里面。
现在要实现在windows下,将相关的控制台输出记录到后台的catalina.out文件中以便将来查看。
1、修改startup.bat中
改call "%EXECUTABLE%" start %CMD_LINE_ARGS%
为call "%EXECUTABLE%" run %CMD_LINE_ARGS%
2、修改catalina.bat中
rem Execute Java with the applicable properties
if not "%JPDA%" == "" goto doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
后面的四段,每段后面加:

   
   
   
   
  1. >> %CATALINA_BASE%\logs\catalina.out 

 

修改如下:
 

   
   
   
   
  1. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% >> %CATALINA_BASE%\logs\catalina.out  
  2.  
  3. goto end  
  4.  
  5. :doSecurity  
  6.  
  7. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% >> %CATALINA_BASE%\logs\catalina.out  
  8.  
  9. goto end  
  10.  
  11. :doJpda  
  12.  
  13. if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda  
  14.  
  15. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% -Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=n %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% >> %CATALINA_BASE%\logs\catalina.out  
  16.  
  17. goto end  
  18.  
  19. :doSecurityJpda  
  20.  
  21. %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% -Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=n %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% >> %CATALINA_BASE%\logs\catalina.out  
  22.  
  23. goto end   

 四、安全配置:
1、D:\tomcat\conf\tomcat-users.xml删除所有用户,改后内容如下:
 

   
   
   
   
  1. xml version='1.0' encoding='utf-8'?> 
  2. <tomcat-users> 
  3. tomcat-users> 

2、设置字符集:
      server.xml中找到
 

   
   
   
   
  1. <Connector port="8080" protocol="HTTP/1.1"   
  2.            connectionTimeout="20000"   
  3.            redirectPort="8443" /> 

 

修改为

   
   
   
   
  1. <Connector port="8080" maxHttpHeaderSize="8192" 
  2.                maxThreads="150" URIEncoding="utf-8" 
  3.                enableLookups="false" redirectPort="8443" acceptCount="100" 
  4.                connectionTimeout="20000" disableUploadTimeout="true" /> 

 

找到

   
   
   
   
  1. <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 

改为:

   
   
   
   
  1. <Connector port="8009" enableLookups="false" redirectPort="8443"   
  2.            protocol="AJP/1.3" URIEncoding="utf-8"/> 

 3、web.xml中,添加rar,iso等的mime-type映射,避免在浏览器里直接打开。

   
   
   
   
  1. <mime-mapping> 
  2.     <extension>mhtextension> 
  3.     <mime-type>text/x-mhtmime-type> 
  4. mime-mapping> 
  5. <mime-mapping> 
  6.     <extension>rarextension> 
  7.     <mime-type>application/octet-streammime-type> 
  8. mime-mapping> 
  9. <mime-mapping> 
  10.     <extension>isoextension> 
  11.     <mime-type>application/octet-streammime-type> 
  12. mime-mapping> 
  13. <mime-mapping> 
  14.     <extension>apeextension> 
  15.     <mime-type>application/octet-streammime-type> 
  16. mime-mapping> 
  17. <mime-mapping> 
  18.     <extension>rmvbextension> 
  19.     <mime-type>application/octet-streammime-type> 
  20. mime-mapping> 
  21. <mime-mapping> 
  22.     <extension>icoextension> 
  23.     <mime-type>p_w_picpath/x-iconmime-type> 
  24. mime-mapping> 

 4、删除示例程序文件夹:D:\tomcat\webapps\examples