Tomcat 5.5 配置

Tomcat 5.5 配置

 

1.

Release Notes: http://tomcat.apache.org/tomcat-5.5-doc/RELEASE-NOTES
Change Log: http://tomcat.apache.org/tomcat-5.5-doc/changelog.html
Downloads: http://tomcat.apache.org/download-55.cgi

jakarta-tomcat-5.5.x.zip

jakarta-tomcat-5.5.x-compat.zip

jakarta-tomcat-5.5.x-admin.zip
(Tomcat
是没有内置admin

Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it. )

都解到同一个目下面。比如:D:\jakarta-tomcat-5.5.x\

(如果使用jdk1.4,才需要compat.zipjdk1.5就可以免了个。)

 

2.修改jakarta-tomcat-5.5.x\conf\tomcat-users.xml.
添加管理员账lizongbo,密码为lizongbopass.
xml如下:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="role1" password="tomcat" roles="role1"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="lizongbo" password="lizongbopass" roles="admin,manager"/>
</tomcat-users>

 

3.修改jakarta-tomcat-5.5.x\conf\server.xml来解决编码问题

(Connector 添加URIEncoding参数
参考 http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx)

(可以置成GB18030)
    <Connector port="8080"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="200"
               connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK"
               compression="on" compressionMinSize="2048"
      noCompressionUserAgents="gozilla, traviata"
      compressableMimeType="text/html,text/xml"/>

 

    <Connector port="8009"
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" URIEncoding="GBK"/>

 

4.启用支持gzip压缩.
(http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&i=81169)
添加下列属性
 compression="on"
      compressionMinSize="2048"
      noCompressionUserAgents="gozilla, traviata"
      compressableMimeType="text/html,text/xml"

 

5.置虚主机。

jakarta-tomcat-5.5.x\下建立文件vhost\www.mydomain.com

然后修改jakarta-tomcat-5.5.x\conf\server.xml

 

<Engine defaultHost="localhost" name="Catalina">
      <Host appBase="vhost/www.mydomain.com" name="www.mydomain.com">
      </Host>
      <Host appBase="webapps" name="localhost">
      </Host>
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
    </Engine>

 

6.添加数据库驱动,更新mail.jaractiovation.jar

mysql-connector-java-3.0.16-ga-bin.jar,pg74.215.jdbc3.jar jakarta-tomcat-5.5.x\common\lib\

javamail 1.3.2mail.jarjaf-1_0_2 activation.jar

msSQl 2000 JDBC sp3msbase.jar,msutil,jar,mssqlserver.jar

 

 

7.配置SSL

参考 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/ssl-howto.html

D:\j2sdk1.4.2_06\bin>%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
keystore  lizongbossl
您的名字与姓氏是什
 
[tomcat5.5.x]  tomcat5.5.x
您的组织单位名称是什
 
[jakarta]  jakarta
您的组织名称是什
  [apache]
  apache
您所在的城市或区域名称是什
  [hzcity]
  hzcity
您所在的州或省份名称是什
  [gdp]
  gdp
该单位的两字母国家代是什
  [CN]
  CN
CN=tomcat5.5.x, OU=jakarta, O=apache, L=hzcity, ST=gdp, C=CN
正确
 
[]  y

 

<tomcat>的主密
       
(如果和 keystore 相同,按回):

(一致,因此直接回)

然后再把userhome(例如:C:\Documents and Settings\lizongbo\)下的.keystore制到

tomcatconf\下。

 (例如:D:\jakarta-tomcat-5.5.x\conf\.keystore )

配置jakarta-tomcat-5.5.x\conf\server.xml

加上

    <Connector port="8443"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
           keystoreFile="conf/.keystore"
           keystorePass="lizongbossl"> <!--
与先前置的密一致-->
    </Connector>

8.禁止文件目列表,

修改jakarta-tomcat-5.5.x\conf\web.xml,把listingfalse

 

    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

 

 9.指定了自己的javaEncoding

(参考 http://gceclub.sun.com.cn/staticcontent/html/sunone/app7/app7-dg-webapp/ch6/ch6-4.html )


    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
                <init-param>
            <param-name>javaEncoding</param-name>
            <param-value>GB18030</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>

 10.添加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>image/x-icon</mime-type>
    </mime-mapping>

10.1对html静态页面设置编码
    <!--  修改下面两行以支持静态超文本的自动编码 -->
    <mime-mapping>
    <extension>htm</extension>
    <mime-type>text/html;charset=gb2312</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html;charset=gb2312</mime-type>
    </mime-mapping>
  </web-app>

 

11.添加welcome-file-list,并序。

 <welcome-file-list>   
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

 

你可能感兴趣的:(Tomcat 5.5 配置)