Tomcat directory structure and configuration files

  • TOMCAT directory structure
    • /bin: Stores script files for starting and closing Tomcat on Windows or Linux platforms
    • /conf: stores various global configuration files of the Tomcat server, the most important of which are server.xml and web.xml
    • /doc: Store Tomcat documentation
    • /server: contains three subdirectories: classes, lib and webapps
    • /server/lib: Stores various JAR files required by the Tomcat server
    • /server/webapps: store the two WEB applications admin application and manager application that come with Tomcat
    • /common/lib: Stores the Tomcat server and jar files that can be accessed by all web applications
    • /shared/lib: Stores jar files that all web applications can access (but cannot be accessed by the Tomcat server)
    • /logs: Stores log files when Tomcat is executed
    • /src: store the source code of Tomcat
    • /webapps: Tomcat's main web publishing directory, by default, web application files are placed in this directory
    • /work: store the class file generated after JSP compilation

CATALINA_HOME is the installation directory of Tomcat

$CATALINA_HOME/conf/server.xml configuration file

1.<Server port="1086" shutdown="SHUTDOWN">

Specify a port, which is responsible for listening to shutdown requests to shut down tomcat

2.  <Service name="Catalina">

Specify the name of the service, usually "Catalina"

3.<Connector executor="tomcatThreadPool"port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"  redirectPort="8443" />

Element attributes (representing the connection between client and service):

port: Specify the port number to be created on the server side, and use this port to listen for requests from clients

maxThreads: The maximum number of threads created by the server

minSpareThreads: Minimum number of remaining threads

maxSpareThreads: the maximum number of remaining threads

enableLookups: If true, you can get the actual host name of the remote client by calling request.getRemoteHost() to perform DNS query. If false, it will not perform DNS query, but return its IP address redirectPort: Specify when the server is processing HTTP The port number to be redirected after receiving an SSL transport request when requesting

acceptCount: Specifies the number of requests that can be placed in the processing queue when all available threads for processing requests are used, and requests that are exceeded will not be processed connectionTimeout: Specifies the number of times to timeout (in milliseconds)

4. <Engine defaultHost="localhost" name="Catalina">
specifies the access host address, usually the machine

5.      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

    • element attribute (representing a virtual host)
    • name: Specify the virtual host name
    • debug: specify the log level
    • appBase: The base directory for storing web applications, which can be an absolute path or a directory relative to $CATALINA_HOME, the default is $CATALINA_HOME/webapps
    • unpackWARs: If true, tomcat will automatically decompress the WAR file and run it, otherwise run the application directly from the WAR file without decompressing it. autoDeploy: If true, it means that Tomcat will automatically publish all web applications in the appBase directory when it starts ( including newly added web applications)

6.<Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>

      </Realm>

Element attribute (representing the database that stores the username, password and role) className: Specifies the class name used by Realm, which must implement the org.apache.catalina.Realm interface

resourceName: here realm is mainly used for tomcat access user authentication, divided into

  1. JDBCRealm  
  2. DataSourceRealm  
  3. JNDIRealm  
  4. UserDatabaseRealm  
  5. MemoryRealm  
  6. JAASRealm  
  7. CombinedRealm  
  8. LockOutRealm 

The UserDatabaseRealm used here corresponds to:

<GlobalNamingResources>

    <Resource auth="Container" description="User database that can be updated and saved"     factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

    name="UserDatabase"

    pathname="conf/tomcat-users.xml"

    type="org.apache.catalina.UserDatabase"/>

  </GlobalNamingResources>

The name here is the resourceName corresponding to the above, and the user information configured by comcat-users.xml is used by default.

7.<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>

configure log;

$CATALINA_HOME/conf/web.xml

This file defines default values ​​for all web applications. If you want to set the corresponding default parameters for different webapps, please specify them in webapp/web.xml of the project APP you want to set.


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

    </welcome-file-list>

Default web welcome home page

<session-config>
        <session-timeout>5</session-timeout>

    </session-config>

This is the session expiration time in minutes

< 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 > false </ param-value >
</ init-param >
< load-on-startup > 1 </ load-on-startup >
</ servlet >

servelt mapping,可以根据不同的情况配置不同的servlet

<load-on-startup>:指定当Web应用启动时,装载Servlet的次序


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324618806&siteId=291194637