Tomcat configuration file server. xml
Server. xml configuration file in the Tomcat directory
Server. xml is called the main configuration file or global configuration file.
It achieves the following two goals:
1. initialize Tomcat components.
2. Describe the structure and meaning of Tomcat so that Tomcat can be started and built by instantiating Components
The code is parsed as follows:
<Server port = "8005" shutdown = "SHUTDOWN"> <Listener className = "org. apache. catalina. core. aprLifecycleListener "SSLEngine =" on "/> <Listener className =" org. apache. catalina. core. jasperListener "/> <Listener className =" org. apache. catalina. core. jreMemoryLeakPreventionListener "/> <Listener className =" org. apache. catalina. mbeans. globalResourcesLifecycleListener "/> <Listener className =" org. apache. catalina. c Ore. ThreadLocalLeakPreventionListener "/> <GlobalNamingResources> <! -- A Global naming resource is used to define some external access resources. Its function is to define the external resources referenced by all engine applications --!> <Resource name = "UserDatabase" auth = "Container" type = "org. apache. catalina. userDatabase "description =" User database that can be updated and saved "factory =" org. apache. catalina. users. memoryUserDatabaseFactory "pathname =" conf/tomcat-users.xml "/> </GlobalNamingResources>
<! -- Defines an authentication resource named "UserDatabase" to load the conf/tomcat-users.xml to the memory, perform authentication in the memory when authentication is required --> <Service name = "Catalina">
<! -- # Define the Service component, which can be associated with ctor and Engine. One Engine can correspond to multiple Connector, and only one Engine in each Service can be created. --!> <Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443"/> <! -- Modify the connection listening port of HTTP/1.1 to 8080. Requests accessed by the client via a browser can only be transmitted to tomcat through HTTP. --> <Connector port = "8009" protocol = "AJP/1.3" redirectPort = "8443"/> <Engine name = "Catalina" defaultHost = "localhost"> <! -- Modify the current Engine. The default host is localhost -->
<Realm className = "org. apache. catalina. realm. lockOutRealm "> <Realm className =" org. apache. catalina. realm. userDatabaseRealm "resourceName =" UserDatabase "/> </Realm> <-- Realm component, which defines the authentication for access to applications in the current container, authenticate through external resource UserDatabase --> <Host name = "localhost" appBase = "webapps" unpackWARs = "true" autoDeploy = "true"> <! -- Define a host with the domain name: localhost. The application directory is webapps. Set automatic deployment, automatic decompression --> <Context path = "" docBase = ""/usr/local/tomcat/webfile "" reloadable = "true"/> <! -- Define the application, access path "", and when the application web. when xml or class changes, the current configuration is automatically reloaded, that is, you do not need to restart tomcat to make the deployed new application take effect --> <Valve className = "org. apache. catalina. valves. accessLogValve "directory =" logs "prefix =" localhost_access_log "suffix = ". txt "pattern =" % h % l % u % t & quot; % r & quot; % s % B "/> <! -- Define a Valve component to record tomcat access logs. The log storage directory is: logs, if defined as a relative path, is equivalent to $ CATALINA_HOME, not relative to appBase,
Note This. Define the log file prefix as localhost_access_logand end with .txt. pattern Defines the log Content format. For specific fields, see the official tomcat documentation --> </Host> </Engine> </Service> </Server>
The tag function is as follows:
Server label: root element, which represents the entire container and is the top-level element of the Tomcat instance. by org. apache. catalina. server interface to define. it contains a <Service> element. it cannot be a child element of any element. (its direct sub-yuan is known as 3)
Listener Tag: Listener, used to manage Tomcat lifecycle and global resources
GlobalNamingResources label: configure the system's JNDI
Service Tag: This element is composed of org. apache. catalina. service Interface Definition. It contains one <Engine> element and one or more <Connector> elements. These Connector elements share the same Engine element (two directly sub-elements)
Connector tag: a Connector that represents an interface between external customers. It listens to customer requests on a specified interface and sends requests to the Engine for processing. The ports between ctor cannot be repeated, otherwise, the jvm bind port conflict is reported.
Enger Tag: Engine. Each Service Element can have only one Engine element. the element processes customer requests received by all <Connector> elements in the same <Service>. by org. apahce. catalina. engine interface definition. process all client requests from the server (three sub-elements)
Realm Tag: defines the authentication for access to applications in the current container, and authenticates through external resource UserDatabase
Logger label:
Host Tag: it is defined by the Host interface. an Engine element can contain multiple <Host> elements. each <Host> element defines a virtual Host. it contains one or more Web applications. the VM processes a specific host request (its direct sub-elements are 2)
Logger Tag: log and error message
Context tag: a web application group defined by the Context interface. is the most frequently used element. each <Context element represents a single Web application running on the VM. one <Host> can contain multiple <Context> elements. each web application has a unique Context that represents the web application itself. the servlet container creates a ServletContext object for the first web application. when a web application is initialized, it loads "web. each Servlet class defined in xml. The <Context> element can contain the following elements: <Logger>, <Realm>, <Resource>, <ResourceParams>
For more Tomcat tutorials, see the following:
Install and configure the Tomcat environment in CentOS 6.6
Install JDK + Tomcat in RedHat Linux 5.5 and deploy Java Projects
Tomcat authoritative guide (second edition) (Chinese/English hd pdf + bookmarks)
Tomcat Security Configuration and Performance Optimization
How to Use Xshell to view Tomcat real-time logs with Chinese garbled characters in Linux
Install JDK and Tomcat in CentOS 64-bit and set the Tomcat Startup Procedure
Install Tomcat in CentOS 6.5
Tomcat details: click here
Tomcat: click here
This article permanently updates the link address: