今天下载了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
后面的四段,每段后面加:
- >> %CATALINA_BASE%\logs\catalina.out
修改如下:
- %_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
- goto end
- :doSecurity
- %_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
- goto end
- :doJpda
- if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
- %_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
- goto end
- :doSecurityJpda
- %_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
- goto end
四、安全配置:
1、D:\tomcat\conf\tomcat-users.xml删除所有用户,改后内容如下:
- <?xml version='1.0' encoding='utf-8'?>
- <tomcat-users>
- </tomcat-users>
2、设置字符集:
server.xml中找到
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
修改为
- <Connector port="8080" maxHttpHeaderSize="8192"
- maxThreads="150" URIEncoding="utf-8"
- enableLookups="false" redirectPort="8443" acceptCount="100"
- connectionTimeout="20000" disableUploadTimeout="true" />
找到
- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
改为:
- <Connector port="8009" enableLookups="false" redirectPort="8443"
- protocol="AJP/1.3" URIEncoding="utf-8"/>
3、web.xml中,添加rar,iso等的mime-type映射,避免在浏览器里直接打开。
- <mime-mapping>
- <extension>mht</extension>
- <mime-type>text/x-mht</mime-type>
- </mime-mapping>
- <mime-mapping>
- <extension>rar</extension>
- <mime-type>application/octet-stream</mime-type>
- </mime-mapping>
- <mime-mapping>
- <extension>iso</extension>
- <mime-type>application/octet-stream</mime-type>
- </mime-mapping>
- <mime-mapping>
- <extension>ape</extension>
- <mime-type>application/octet-stream</mime-type>
- </mime-mapping>
- <mime-mapping>
- <extension>rmvb</extension>
- <mime-type>application/octet-stream</mime-type>
- </mime-mapping>
- <mime-mapping>
- <extension>ico</extension>
- <mime-type>p_w_picpath/x-icon</mime-type>
- </mime-mapping>
4、删除示例程序文件夹:D:\tomcat\webapps\examples
转载于:https://blog.51cto.com/xuchenguang/419836