Tomcat General Configuration

Source: Internet
Author: User
Tags define session

Description of each configuration file:

Server.xml The core configuration file.

context.xml provides a default configuration for all Web applications deployed on this Tomcat instance. Each webapp can use a unique context.xml, typically in a meta-inf or Web-inf subdirectory in the WebApp directory, and is commonly used to define session manager, realm, and JDBC.

Web. XML Provides a default deployment descriptor for all Web applications deployed on this Tomcat instance (information related to deployment, such as what classes are loaded, how to load, where to load, and so on), to provide basic servlet definitions and MIME mapping tables for WebApp.

Tomcat-user.xml The relevant roles, users, and passwords used in the realm certification; the manager of the Tomcat comes with this file by default, and the user is added/removed from Tomcat. Assigning a role to a user, etc. will be implemented by editing this file.

Catalina.policy This profile is read when the Tomcat instance is launched based on the security option; This file is a Java secure policy configuration file that configures permissions to access codebase or some Java class.

catalina.properties The Java attribute definition file, sets the class loader path, the security pack list, and some parameter information for tuning performance.

logging.properties defines log-related configuration information, such as log levels, file paths, and so on.


The following are the Server.xml configuration files. Note that the first letter of the component is case-sensitive and uppercase.

First, the initial knowledge configuration components

The configuration file is a hierarchy that is configured in a way. Each level is implemented by the class that tomcat comes with. Also known as components. This is a class library that is part of the web except for JSPs and Sevlet libraries.

Below is a hierarchical diagram of common components:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5F/wKioL1Ybo7uC2cCGAAB1-XEkGPs901.jpg "title=" 7.JPG " alt= "Wkiol1ybo7uc2ccgaab1-xekgps901.jpg"/>

This is about the same structure, and there are many components that are not listed. Roughly all of the components can be divided into several categories:

Top-level components Also known as server
Container class Can contain other components of the
Connector components Connector, used to listen for addresses and ports
Components that are nested classes is contained in a container class component and cannot contain other components


The various common components are explained in detail:

1, Server, which represents a tomcat instance running in the JVM, which is the process of Tomcat. Each tomcat can have only one process, multiple threads. And there can be only one Tomcat instance in a JVM. You can also run multiple jvm+tomcat, as long as it's not the same socket, but what's the point? There can be more than one service in the server, but it is generally not fun.

2, Service (services), used to connect the connector to the engine, a service can have multiple connector, but only one engine. That is, multiple listening addresses and ports are linked to the same engine.

3, Connector (connector), simply said to be used to listen to the address and port, received the request to the engine to deal with. There are two main types of connectors for Apache: One is apache2.2 previously used mod_jk, and one is later mod_proxy. And the Connection agreement aspect. MOD_JK is generally used only AJP connection, and Mod_proxy has HTTP and AJP two kinds. This is when we are learning that the front end is Apache or Nginx.

AJP protocol: Apache Jserv protocal, can only be used between Apache and Tomcat. Nginx or browser can only use HTTP.


Container Class Components:

4, Engine (engines), usually refers to the Catalina Servlet engine. is a core component that provides JSP parsing, JSP translation, compiling, and providing services to the outside. Responsible for receiving user requests through connector. and the HTTP header is checked to the different host.

5,host, host components similar to the virtual host in Apache, each host is a separate virtual host. Support for FQDN-based virtual hosts. Of course there are other ways to implement a virtual host based on other means. An engine must contain at least one host.

6. Context (contextual), a context represents a Web application. Used to specify the root directory of the corresponding Web program code, and some additional attributes, such as how to deploy. There can be more than one in a host. Used to define the deployment of an application. is the container class component of the most internal layer.


Nested class (nested) components:

7, Valve, intercepts the request and processes it before it is forwarded to the corresponding Web application. Can be used in any container.

8, Logger (logger), used to record the status information inside the component. Can be used in any container other than the context. and is inheritable. As defined at the engine level, the following levels are inherited if they are not defined.

9, realm (domain), can be used in any container class components. Associate a user authentication library for authentication and authorization. Can be inherited. When you define role access control for your application, you are implementing it in realm.



Second, the component properties

1. Server:

Cases:

<server port= "8005" shutdown= "Shutdown" >

Allows an administrator to close an instance by accessing Telnet 8005 port and entering shutdown. It is generally not used.

Port: The command on which port to accept the shutdown service. Only native access is allowed by default.

Shutdown: What string is received after executing the instruction to close the service.

[[Email protected] ~]# telnet 127.0.0.1 8005Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is ' ^] '. SHUTDOWN #不能有空格Connection closed by foreign host.

2. Service:

Cases:

<service name= "Catalina" >

Name: The default is Catalina for this service, and the name appears in the relevant log information.

3, Connector:

Cases:

<connector port= "protocol=" http/1.1 "enablelookups=" false "connectiontimeout=" 20000 "maxthreads=" 500 " minsparethreads= "" Maxsparethreads= "/>"

The two connection protocols are HTTP and AJP. There are several classifications in HTTP. The http/1.1 that appears here in protocol is the default way of HTTP connection, and here's just a look. We are now in the client browser to access, we can only use the HTTP protocol.


Address: The location of the listener, all addresses by default.

MaxThreads: Maximum number of concurrent connections, default 200.

Minsparethreads: Minimum number of idle threads.

Maxsparethreads: Maximum number of idle threads.

PORT: Listen for ports.

Protocol: The protocol used by the connector, which defaults to http/1.1, is typically ajp/1.3 when the AJP protocol is defined

Redirectport: If it is a connector for the HTTP protocol, after receiving the HTTPS connection, go to the port defined by this property.

ConnectionTimeout: Waits for the client to send a request for a time-out, in milliseconds, by default of 60000.

Enablelookups: The hostname of the reverse client. The default is true. Recommended false.

Acceptcount: The length of the wait queue.


If it is an HTTPS connection, add a lot of attributes as well. Copy an example from the official website:

Http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html

<!--Define a SSL Coyote http/1.1 Connector on port 8443--><connector protocol= "org.apache.coyote.http           11.http11aprprotocol "port=" 8443 "maxthreads=" + "scheme=" https "secure=" true "sslenabled=" true "           Sslcertificatefile= "/USR/LOCAL/SSL/SERVER.CRT" sslcertificatekeyfile= "/usr/local/ssl/server.pem" sslverifyclient= "optional" sslprotocol= "tlsv1+tlsv1.1+tlsv1.2"/>


4. Engine:

Cases:

<engine name= "Catalina" defaulthost= "localhost" >


Name: Defines the names that will appear in the relevant logs.

Defaulthost: If the sent connection does not recognize which host the virtual host is defined by, the host specified by this property is issued.


5. Host

Cases:

The program project that represents the www.a.com virtual host is under the/www/a.com path, and the program code is generally in the subordinate directory, and of course it can be in this directory.

and the main program in the/www/a.com/root directory, the URL is the Www.a.com;bbs program in the/www/a.com/bbs directory, the URL is Www.a.com/bbs;blog program in the/www/a.com/blog directory, The URL is www.a.com/blog.


The directory where the Appbase:web program resides is the root directory where the Web project resides. The absolute path can be used, and if it is a relative path, it is relative to the path in the variable catalina_home variable.

Autodeploy: Whether application files placed in the AppBase directory are automatically deploy when Tomcat is in the running state, and default to TRUE;

Unpackwars: Whether to automatically expand the archive file for the war format in the AppBase directory;


There is also a small container component that is not written, but is associated with host: <alias></alias>, which defines the alias of host name.

As above my host name is www.a.com, if I also want to have a name to access the program specified by host, you can:


6. Context:

Cases:

There are roughly two functions,

One is similar to the path alias alias in Apache, a context definition is used to identify the path where a Web application code resides and the associated URI. Although the directory name here is the same as the path in the URI, the same effect is different.

The second is the static deployment,

Although we have defined Autodeploy automatic deployment in host, sometimes some regulation regulation may be because the file is more or more complex, open from the web is blank, this automatic deployment is unsuccessful. Define the context to specifically specify the location of the code, which is static deployment.

Deployment: Leave the program in a pending state. Compiles and loads the class library files that are dependent on the class loader. You can run the response directly as soon as the user requests it.

Each JSP program needs to be deployed before it can be run.

It is divided into static deployment and dynamic deployment, that is, without restarting Tomcat.

Because JSP is a program file, it is not the same as a Web page file in another format.


Docbase:web the location of the application code, if it is a relative path, relative to the path of the host's appbase.

Path: The URI relative to the Web server root path. If "" is empty, the expression is the root directory.

Reloadable: Indicates whether to allow reloading of the Web application's class, the program will load the relevant class when it is installed, and here is whether to reload it, I think it should mean that there are other programs have loaded the relevant class, when the deployment of this program will be reloaded again. The default is false;



Third, use the Tomcat comes with the application

After you have installed Tomcat and started it, you can open it. The Web page is too big to be part of the cut.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/6D/wKiom1YcwH3QPVyPAADu8F08LRI330.jpg "title=" 6.JPG " alt= "Wkiom1ycwh3qpvypaadu8f08lri330.jpg"/>

These three are state information, application management, and virtual host management respectively. You will be prompted to enter your account when you open it, and you will be prompted to do so directly.

The above two and the third user's role permissions are different, we first look at the first two.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/6A/wKioL1YcwhmgjzaBAAFmu4MM7zI946.jpg "title=" 8.JPG " alt= "Wkiol1ycwhmgjzabaafmu4mm7zi946.jpg"/>

Follow the prompts to add users to the profile tomcat-users.xml.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/6D/wKiom1YcwruRHdieAAEUk0jgDyc358.jpg "title=" 9.JPG " alt= "Wkiom1ycwrurhdieaaeuk0jgdyc358.jpg"/>

<!----> is a comment, a lot of comments in this file, be careful not to write into the comments. Then reboot tomcat to log in.

The first is the status information, each of the two is a management application, which can be installed within the application.

The third one is also done as prompted. I am here to use the same user, a user has two role permissions can be. The result looks like this:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/6E/wKiom1YcxcHweWFCAAB3zS7icWA311.jpg "title=" 10.JPG "alt=" Wkiom1ycxchwewfcaab3zs7icwa311.jpg "/>

Here too, you can dynamically increase the virtual host, but directly add to the memory, will not write to the configuration file.


Just write here, are some simple operation, welcome you to browse.


This article is from the "Big Tomato" blog, be sure to keep this source http://fanqie.blog.51cto.com/9382669/1702576

Tomcat General Configuration

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.