1. The origin of tomcat
Origin of Name: Tomcat was originally developed by Sun's software architect James Duncan Davidson. He later helped turn it into an open source project and contributed by Sun to the Apache Software Foundation. Since most open source projects O'Reilly will publish a related book and design its cover as a sketch of an animal, he hopes to name the project after an animal. Because he wanted the animal to take care of itself, he eventually named it tomcat (male cat).
1. Tomcat application scenarios
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 concurrent users. It is the first choice for developing and testing JSP programs. Generally speaking, although Tomcat has the function of processing HTML pages like web servers such as apache or Nginx, it is far less capable of processing static pages than apache or Nginx. Therefore, Tomcat is generally used as a servlet and JSP container and runs separately on the backend.
2. The dependency software required by Tomcat
JDK must be installed before installing Tomcat, a software development toolkit for Java language provided by Sun, which contains Java Virtual Machine (JVM). The written Java source program can form Java bytecode after being compiled. As long as JDK is installed, the JVM can be used to interpret these word code files, thereby ensuring the cross-platformity of Java.
In terms of platform compatibility, JDK is a Java virtual machine that interprets bytecode files and calls the operating system's API to implement corresponding functions. It 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 (the JDK is installed by default, and if it is a Centos 6.0 operating system, it needs to be installed by itself).
1) Check whether JDK is installed
[root@centos02 ~]# java -version openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-b12) OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
2) Centos 6.0 installation JDK
[root@centos02 ~]# mount /dev/cdrom /mnt/ <!--mount Linux CD-ROM-->mount: /dev/sr0 Write protection,Will be mounted read-only [root@centos02 ~]# tar zxvf /mnt/ -C /usr/src/ <!--DecompressjdkSoftware Package--> [root@centos02 src]# ls debug jdk1.7.0_65 kernels [root@centos02 src]# mv jdk1.7.0_65/ /usr/src/java <!--Installation JDK-->[root@centos02 ~]# vim /etc//<!--Configure jdk running environment variables-->export JAVA_HOME=/usr/local/java export PATH=$PATH:$JAVA_HOME/bin [root@centos02 ~]# chmod +x /etc//<!--Add execution permissions for variables-->[root@centos02 ~]# source /etc// <!--runJDK-->
2. Tomcat configuration related instructions
1. Tomcat's main directory
The main directory of tomcat is /usr/local/tomcat8/.
[root@centos02 ~]# cd /usr/local/tomcat/ [root@centos02 tomcat]# ll Total usage 96 drwxr-xr-x 2 root root 4096 11moon 30 19:48 bin drwxr-xr-x 3 root root 174 11moon 30 20:03 conf drwxr-xr-x 2 root root 4096 11moon 30 19:48 lib -rw-r--r-- 1 root root 56812 5moon 20 2014 LICENSE drwxr-xr-x 2 root root 197 11moon 30 19:51 logs -rw-r--r-- 1 root root 1192 5moon 20 2014 NOTICE -rw-r--r-- 1 root root 8974 5moon 20 2014 RELEASE-NOTES -rw-r--r-- 1 root root 16204 5moon 20 2014 drwxr-xr-x 2 root root 30 11moon 30 19:48 temp drwxr-xr-x 7 root root 81 5moon 20 2014 webapps drwxr-xr-x 3 root root 22 11moon 30 19:51 work
The main directory description is as follows:
|---bin/: Store script files to start and close Tomcat on Windows or Linux platforms;
|---conf/: Store various global configuration files of Tomcat server, the most important of which is and;
|---lib/: Stores the library files required for Tomcat to run;
|---logs/: Stores the LOG file when Tomcat is executed;
|---webapps: Tomcat's main web publishing directory (including application examples);
|---work: store the class file generated after JSP compilation;
2. Configuration file description
[root@centos02 tomcat]# ll conf/ Total usage 200 drwxr-xr-x 3 root root 23 11moon 30 19:51 Catalina -rw------- 1 root root 12257 5moon 20 2014 -rw------- 1 root root 6294 5moon 20 2014 -rw------- 1 root root 1394 5moon 20 2014 -rw------- 1 root root 3288 5moon 20 2014 -rw------- 1 root root 6610 11moon 30 20:03 -rw------- 1 root root 1530 5moon 20 2014 -rw------- 1 root root 163385 5moon 20 2014
The configuration file description is as follows:
: Permission control configuration file;
: Tomcat attribute configuration file;
: Context configuration file;
: Log log related configuration files;
: Main configuration file;
: manager-gui manages user configuration files (After installing Tomcatt provides a manager-gui management interface, which enables access by configuring the file);
: Tomcat's servlet, servlet-mapping, filter, MIME and other related configurations;
3. Tomcat main configuration file description
It is the main configuration file of Tomcat. By configuring this file, you can modify Tomcat's startup port, website directory, virtual host, and enable https and other important functions.
The entire structure consists of the following structures: <Server>, <Service>, <Connector /><Engine>, <Host>, <Context>, </Context></Host></Engine></Service> and </Server>.
The following is part of the content of the default installation file, where the contents in <!-- --> are commented. //The beginning of the number is annotation made by me:
[root@Centos01 tomcat8]# vim conf/ <?xml version="1.0" encoding="UTF-8"?> ............ //Omit some content<Server port="8005" shutdown="SHUTDOWN"> //Tomcat closes the port, which is only open to the local address by default. It can be accessed through Telnet 127.0.0.1 8005 on the local machine.//Check Tomcat............ // Some content is omitted here <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> //The default port number 8080 launched by Tomcat can be changed as needed............. // Some content is omitted here <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> //The default port number when Tomcat starts the AJP 1.3 connector, it can be changed as needed............ // Some content is omitted here//The following is the configuration and log configuration when Tomcat defines the virtual host<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/ --> <!-- <Valve className="" /> --> <!-- Access log processes all example. Documentation at: /docs/config/ Note: The pattern used is equivalent to using pattern="common" --> <Valve className="" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server>
4. Description of components of Tomcat server
1)Server
The server element represents the entire CatAlina servlet container.
2)Service
Service is a collection that consists of one or more Connectors, and an Engine (responsible for handling all client requests obtained by Connectors).
3)Connector
A Connector listens to client requests on a specified port and handes the obtained request to Engine for processing, obtains a response from Engine and returns to the client.
Tomcat has two typical Connectors, one listens directly on http requests from browsers and one listens on requests from other webservers.
Coyote HTTP/1.1 Connector listens for http requests from the client browser at port 8080.
Coyote JK2 Connector listens for servlet/jsp proxy requests from other text servers (Apache) at port 8009.
4)Engine
Under Engine, you can configure multiple virtual hosts, and each virtual host has a domain name.
When Engine gets a request, it matches the request to a certain host and then hands the request to the host for processing.
Engine has a default virtual host, and when the request cannot match any host, it will be handed over to the default host for processing.
5)Host
Host represents a virtual host, that is, virtual host, each virtual host matches a certain network domain name Domain Name.
One or more web apps can be deployed under each virtual host, each web app corresponds to a Context and has a Context path.
When the host obtains a request, the request will be matched to a Context, and then the request will be handed over to the Context for processing. The matching method is "longest match", so a Context with path=="" will become the default Context of the Host.
All requests that cannot match the pathname of other Context will eventually match the default Context.
6)Context
A Context corresponds to a web application, and a web application consists of one or more servlets.
Summarize
The above is the Tomcat server of the Centos 7 system introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!