Tomcat configuration method summary

Source: Internet
Author: User

1. download the http://www.eu.apache.org/dist/jakarta/tomcat-5/
here, In jakarta-tomcat-5.0.28.exethere is a previous admin, in jakarta-tomcat-5.5.9.exe there is no default admin module installed, then http: // 127.0.0.1: when 8080/admin is enabled,
Tomcat's administration Web application is no longer installed by default appears. download and install the "admin" package to use it.
so now we need to download the "admin" package
to bring jakarta-tomcat-5.5.x.zip and jakarta-tomcat-5.5.x-comp At.zip and jakarta-tomcat-5.5.x-admin.zip
three files are decompressed in the same directory
(if you use jdk1.4, then compat.zip with jdk1.5 can be exempted from this .)

2. Modify jakarta-tomcat-5.5.x \ conf \ tomcat-users.xml.
Add the Administrator account lizongbo with the password lizongbopass.
The new XML is as follows :(In the initial stage, there is no administrator account and password. Therefore, you cannot log on to the Management page before setting the password. The Administrator account and password can be customized. You do not need to use lizongbo/lizongbopass.)
<? 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>

Sometimes make some modifications in % catalina_home % \ Server \ webapps \ admin \ WEB-INF \ WEB. xml

<! -- Security is active on entire directory -->
<Security-constraint>
<Display-Name> Tomcat server configuration security constraint </display-Name>
<Web-resource-collection>
<Web-resource-Name> Protected Area </Web-resource-Name>
<! -- Define the context-relative URL (s) to be protected -->
<URL-pattern> *. jsp </url-pattern>
<URL-pattern> *. DO </url-pattern>
<URL-pattern> *. html </url-pattern>
</Web-resource-collection>
<Auth-constraint>
<! -- Anyone with one of the listed roles may access this area -->
<Role-Name> admin </role-Name>
</Auth-constraint>
</Security-constraint>

<! -- Login configuration uses form-based authentication -->
<Login-config>
<Auth-method> form </auth-method>
<Realm-Name> Tomcat server configuration form-based authentication area </realm-Name>
<Form-login-config>
<Form-login-page>/login. jsp </form-login-page>
<Form-error-page>/error. jsp </form-error-page>
</Form-login-config>
</Login-config>

<! -- Security roles referenced by this Web Application -->
<Security-role>
<Description>
The role that is required to log in to the Administration Application
</Description>
<Role-Name> admin </role-Name>
</Security-role>
Whether authentication or authorization (permission control only sets the relevant admin role, when you want to add or modify the relevant AA, you must modify this file, to meet your environment.
3. Modify the jakarta-tomcat-5.5.x \ conf \ Server. XML to solve the encoding problem.
(Add uriencoding parameters to connector, refer to http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx)
(It can be set to gb18030)
<Connection 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"/>

<Connection Port = "8009"
Enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3" uriencoding = "GBK"/>

4. enable support for gzip compression.
(Http://www.linuxaid.com.cn/forum/showdoc.jsp? L = 1 & I = 81169)
Add the following attributes
Compression = "on"
Compressionminsize = "2048"
Nocompressionuseragents = "gozilla, Traviata"
Compressablemimetype = "text/html, text/XML"

5. Set the VM.
Create the folder vhost \ www.mydomain.com under jakarta-tomcat-5.5.x.
Then modify jakarta-tomcat-5.5.x \ conf \ Server. xml

<Engine defaulthost = "localhost" name = "Catalina">
<Host appbase = "vhost/www.mydomain.com" name = "http://www.mydomain.com/">
</Host>
<Host appbase = "webapps" name = "localhost">
</Host>
<Realm classname = "org. Apache. Catalina. realm. userdatabaserealm"/>
</Engine>

6. Add the database driver and update Mail. jar and actiovation. jar.
Copy mysql-connector-java-3.0.16-ga-bin.jar, pg74.215.jdbc3. jar to jakarta-tomcat-5.5.x \ common \ Lib \
And javamail 1.3.2 mail. jar, jaf-1_0_2 activation. Jar
MSSQL 2000 JDBC SP3, msbase. jar, msutil, jar, MSSQLServer. Jar


7. Configure SSL
Reference 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
Enter the keystore password: lizongbossl
What is your first name and last name?
[Tomcat5.5.x]: tomcat5.5.x
What is the name of your organization?
[Jakarta]: Jakarta
What is your organization name?
[Apache]: Apache
What is the name of your city or region?
[Hzcity]: hzcity
What is the name of your state or province?
[GDP]: GDP
Two-letter country in the unit Code What is
[CN]: CN
CN = tomcat5.5.x, ou = Jakarta, O = Apache, L = hzcity, St = GDP, c = cn correct?
[No]: Y

Enter the master password of <Tomcat>
(If the password is the same as the keystore password, press Enter ):

(The password must be consistent, so press enter directly)
Then copy the. keystore under userhome (for example, c: \ Documents ents and Settings \ lizongbo \)
In the conf \ directory of Tomcat.
(Example: D: \ jakarta-tomcat-5.5.x \ conf \. keystore
Configure jakarta-tomcat-5.5.x \ conf \ Server. xml
Add
<Connection 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"> <! -- Consistent with the previously set password -->
</Connector>
8. Disable the file directory list,
Modify jakarta-tomcat-5.5.x \ conf \ WEB. xml and set listing to false

<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. You have specified your own javaencoding.
(Reference 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. Add mime-type ing for RAR and ISO
Avoid opening it directly in the browser.
<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 set encoding for HTML static pages
<! -- Modify the following two lines to support Automatic Static hypertext encoding.
-->
<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. Add welcome-file-list and adjust the order.
<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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.