In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
A brief introduction to Tomcat services
Tomcat server is a free and 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 access users. It is the first choice for developing and debugging JSP programs. Generally speaking, although Tomcat has the same function of dealing with HTML pages as Web servers such as Apache or Nginx, because its ability to handle static HTML is far less than that of Apache or Nginx, Tomcat usually runs on the back end as a Servlet and JSP container. As shown in the figure:
Since the 5.x version, the performance of Tomcat has been greatly improved, coupled with its open framework and secondary development and other features, it can be used in the production environment where the traffic is not very large. At present, most e-commerce websites used for the development of JSP technology have basically applied Tomcat.
Second, install Tomcat service
JDK must be installed before Tomcat can be installed. JDK, whose full name is Java Development Kit, is a free Java language software development kit provided by Sun, which includes 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 bytecode files, thus ensuring the cross-platform nature of Java.
In terms of platform compatibility, JDK, as a Java virtual machine that interprets bytecode files and calls operating system API to achieve corresponding functions, is closely related to the type of operating system and the number of platform bits, so there are different types of versions, and Tomcat also has the above characteristics. Centos 7 has JDK installed by default. So just download the Tomcat software.
The package used in this case is apache-tomcat-8.5.16.tar.gz network disk link: https://pan.baidu.com/s/11Puem2_pMMhEnWAgriJ-sA
Extraction code: 3mzo
(1) check the Java environment [root@localhost ~] # java-versionopenjdk version "1.8.0x102" OpenJDK Runtime Environment (build 1.8.0_102-b14) OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode) / / check with the command, and the installation has been completed. (2) install and configure Tomcat
The installation of the Tomcat service is very simple, as follows:
[root@localhost] # tar zxf apache-tomcat-8.5.16.tar.gz-C / usr/src [root@localhost ~] # mv / usr/src/apache-tomcat-8.5.16/ / usr/local/tomcat8// because the Tomcat software is very simple and does not need to be installed / / for future use, it is recommended to change the decompressed directory And rename it [root@localhost ~] # / usr/local/tomcat8/bin/startup.sh / / use the startup script included with the Tomcat program to start the Tomcat service Using CATALINA_BASE: / usr/local/tomcat8Using CATALINA_HOME: / usr/local/tomcat8Using CATALINA_TMPDIR: / usr/local/tomcat8/tempUsing JRE_HOME: / usrUsing CLASSPATH: / usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/ Tomcat-juli.jarTomcat started. [root@localhost ~] # netstat-anpt | grep 8080tcp6 0 0: 8080: * LISTEN 3493/java / / View its listening port (the default port for Tomcat service is 8080) [root@localhost ~] # firewall-cmd-- add-port=8080/tcpsuccess// opens the firewall and its service port (3) client access
3. Detailed explanation of Tomcat configuration file (1) Tomcat configuration instructions
The home directory just installed and moved is / usr/local/tomcat8/.
The total amount of [root@localhost] # ll / usr/local/tomcat8/ is 92drwxr / usr/local/tomcat8/. 2 root root 4096 September 4 23:56 bindrwx-. 3 root root 254 September 4 23:57 confdrwxr-x---. 2 root root 4096 September 4 23:56 lib-rw-r-. 1 root root 57092 June 22 2017 LICENSEdrwxr-x---. 2 root root 240 September 5 00:02 logs-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 September 4 23:56 tempdrwxr-x---. 7 root root 81 June 22 2017 webappsdrwxr-x---. 3 root root 22 September 4 23:57 work
Main catalog description:
Bin: store script files to start or shut down Tomcat on Windows or Linux platform; conf: store various global configuration files of Tomcat server, the most important of which are server.xml and web.xml;lib: store library files needed for Tomcat operation (JARS); logs: store LOG files when Tomcat is executed; webapps:Tomcat 's main Web release directory (including application instances); work: store class files generated after JSP compilation. The total amount of [root@localhost] # ll / usr/local/tomcat8/conf/ is 224drwxr / usr/local/tomcat8/conf/. 3 root root 23 September 4 23:57 Catalina-rw-. 1 root root 13816 June 22 2017 catalina.policy-rw-. 1 root root 7376 June 22 2017 catalina.properties-rw-. 1 root root 1338 June 22 2017 context.xml-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-rw-. 1 root root 7511 June 22 2017 server.xml-rw-. 1 root root 2164 June 22 2017 tomcat-users.xml-rw-. 1 root root 2633 June 22 2017 tomcat-users.xsd-rw-. 1 root root 168251 June 22 2017 web.xml
The main profile description:
Catalina.policy: permission control configuration file; catalina.properties:Tomcat attribute configuration file; context.xml: context configuration file; logging.properties: log log-related configuration file; server.xml: main configuration file; tomcat-users.xml:manager-gui management configuration file (a manager management interface is provided by default after Tomcat installation, which can be accessed by configuring this file); web.xml:Tomcat servlet, servlet-mapping, filter, MIME and other related configurations. (2) description of Tomcat main configuration file
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, in which the contents are annotated (comments have been attached to frequently modified areas).
[root@localhost] # vim / usr/local/tomcat8/conf/server.xml. / / some contents are omitted / / Tomcat closes the port. By default, it is only available for local addresses. It can be accessed locally through Telnet 127.0.0.1 8005. / / A pair of Tomcat is closed. / / part of the content is omitted / / the default port number started by Tomcat is 8080, which can be changed as needed. . / / omit some of the contents / / the default port number when Tomcat starts the AJP 1.3 connector, which can be changed as needed. / / some of the contents are omitted / / the following is the configuration and log configuration when defining virtual hosts for Tomcat (3) description of the components of Tomcat Server 1) Server
The server element represents the servlet container for the entire CatAlina.
2) Service
A Service is a collection of one or more Connector and an Engine (responsible for processing all customer requests obtained by Connector).
3) 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 listens directly for http requests from browser, and one listens for requests from other webserver.
Coyote HTTP/1.1 Connector listens for http requests from customer browser (browsing) at port 8080; Coyote JK2 Connector listens for servlet/jsp proxy requests from other text server (Apache) at port 8009. 4) 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.
5) 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.
6) Context
A Context corresponds to a web application, and a web application consists of one or more servlet.
Fourth, establish the virtual directory site of Java (1) set up the virtual directory Used to store the website file [root@localhost] # mkdir-p / web/webapp (2) set up a test file written in Java language [root@localhost] # vim / web/webapp/index.jsp JSP test1 page (3) modify the main configuration file of Tomcat [root@localhost ~] # vim / usr/local/tomcat8/conf/server.xml... / / omit part of the content / / host defines a virtual host, domain name defines application base directory for localhost,appBase, unpackWARs definition automatically decompresses, autoDeploy definition automatically deploys / / context defines a web application (virtual directory), path specifies access directory, docBase defines web page directory when the application changes. Automatically load without restarting tomcat (manually adding content) [root@localhost ~] # / usr/local/tomcat8/bin/shutdown.sh [root@localhost ~] # / usr/local/tomcat8/bin/startup.sh// restart Tomcat service (4) client access test
This means that the Tomcat service virtual directory has taken effect!
-this is the end of this article. Thank you for reading-
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.