Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed description of Tomcat server configuration

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Tomcat server is a free open source web application server, which is a lightweight application server. It is widely used in small and medium-sized systems and not many concurrent users. It is the first choice for developing and testing JSP programs. Generally speaking, although Tomcat is the same as apache or Nginx web servers, it has the function of dealing with HTML pages, but its ability to deal with static pages is far less than apache or Nginx, so Tomcat generally runs on the back end as a servlet and JSP container.

For more information about the deployment process and application environment of Tomcat server, please refer to the blog post: https://blog.51cto.com/14154700/2412180.

The main purpose of this blog post is to talk about the role of Tomcat configuration files and related instructions.

Before installing Tomcat, you must install JDK,JDK, a free Java language software development kit provided by sun, which includes the Java Virtual Machine (JVM). The written Java source program can be compiled to form Java bytecode. As long as you install JDK, you can use JVM to interpret these code files, thus ensuring the cross-platform nature of Java.

In terms of platform compatibility, JDK, as a Java virtual machine that interprets the bytecode file and calls the operating system's API to achieve the corresponding function, is closely related to the operating system type and the number of platform bits, so there are different types of versions, and Tomcat also has these characteristics. JDK has been installed by default, so you can use the following command to check whether JDK is installed:

[root@localhost ~] # java-version # check whether JDK is installed. If not, install openjdk version "1.8.0mm 161" OpenJDK Runtime Environment (build 1.8.0_161-b14) OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode) by yourself.

The configuration process of Tomcat is not discussed in this blog post. The blog link to the configuration process has been given above. If necessary, you can refer to that blog post. Now let's talk about its configuration file description:

1. The main catalogue description:

[root@localhost ~] # cd / usr/local/tomcat8/ # switch to the Tomcat directory [root@localhost tomcat8] # ll # to view the total amount of all the contents under the directory 92drwxrkashi-2 root root 4096 June 22 20:08 bin # stores the script file drwx- 2 root root 238 June 22 2017 conf# for starting and shutting down Tomcat on Windows or Linux platform Store various global configuration files for the Tomcat server The most important of these are server.xml and web.xmldrwxr-x--- 2 root root 4096 June 22 20:08 lib# stores the library files needed for Tomcat operation-rw-r- 1 root root 57092 June 22 2017 LICENSEdrwxr-x--- 2 root root June 22 2017 logs# stores log files for Tomcat execution-rw-r- 1 root root 1723 June 22 2017 NOTICE-rw-r- 1 root Root 7064 June 22 2017 RELEASE-NOTES-rw-r- 1 root root 15946 June 22 2017 RUNNING.txtdrwxr-x--- 2 root root 30 June 22 20:08 tempdrwxr-x--- 7 root root 81 June 22 2017 webapps#Tomcat 's main web release directory (including application examples). Drwxr-x--- 2 root root June 22 2017 work# stores the class files generated by JSP compilation.

2. Configuration file description:

[root@localhost tomcat8] # ll conf # View the total amount of content in the conf directory 224murrw1 root root 13816 June 22 2017 catalina.policy # access control profile-rw- 1 root root 7376 June 22 2017 catalina.properties # Tomcat attribute profile-rw- 1 root root 1338 June 22 2017 context.xml # context profile-rw- 1 root root 1149 June 22 2017 jaspic-providers.xml-rw- 1 root root 2358 June 22 2017 jaspic-providers.xsd-rw- 1 root root 3622 June 22 2017 logging.properties # Log log related profile-rw- 1 root root 7511 June 22 2017 server .xml # main profile-rw- 1 root root 2164 June 22 2017 tomcat-users.xml # manager-gui Management profile # Tomcat provides a manager management interface by default after installation Access can be enabled by configuring the file. -rw- 1 root root 2633 June 22 2017 tomcat-users.xsd-rw- 1 root root 168251 June 22 2017 web.xml

3. Tomcat main configuration file description:

Server.xml is the main configuration file of Tomcat. By configuring this file, you can modify the startup port of Tomcat, website directory, virtual host, open https and other important functions.

The whole server.xml consists of the following structures:, and.

The following is part of the default installation of the server.xml file, which contains annotated information. I wrote a note at the beginning of the # sign:

[root@localhost tomcat8] # vim conf/server.xml. # omit part of the content # Tomcat closes the port, which is only open to local addresses by default, and can be accessed locally through Telnet 127.0.0.1 8005, and # closes Tomcat. # omit part of the content # Tomcat launches the default port number 8080, which can be changed as needed. . # omit part of the content # Tomcat starts the AJP 1.3 connector with the default port number, which can be changed as needed. # omit part of the content # the following defines the configuration and log configuration of virtual hosts for Tomcat

4. Description of the components of Tomcat server:

① Server

The server element represents the servlet container for the entire CatAlina.

② Service

A Service is a collection of one or more Connector and an Engine (responsible for processing all customer requests obtained by Connector).

③ Connector

A Connector listens for customer requests on a specified port and passes the obtained requests to the Engine for processing, gets a response from the Engine and returns to the customer.

Tomcat has two typical Connector, one listening directly for http requests from browser, and one listening for requests from other webserver. Coyote HTTP/1.1 Connector listens for http requests from the customer browser (browsing) at port 8080. Coyote JK2 Connector listens for servlet/jsp proxy requests from other text server (Apache) at port 8009.

④ Engine:

Multiple virtual hosts virtual host can be configured under Engine, each with a domain name.

When Engine gets a request, it matches the request to a Host and then passes the request to the host for processing.

Engine has a default virtual host that will be handed over to the default host when the request cannot be matched to any host.

⑤ Host

Host represents a virtual Host (virtual host), and each virtual host matches a network domain name, Domain Name.

One or more web app can be deployed under each virtual host, with each web app corresponding to a Context and a Context path.

When host gets a request, it matches the request to a Context and then passes the request to the Context for processing. The matching method is "longest match", so a Context of path== "" will become the default Context for that Host.

All requests that cannot match the pathnames of other Context will eventually match that default Context.

⑥ Context

A Context corresponds to a web application, and a web application consists of one or more servlet.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report