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

Tomcat service installation-can be followed (easy to do)

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

Share

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

Tomcat introduction

1. Free, open source Web application server

2. A core project in the Jakarta project of Apache Software Foundation (Apache Software Foundation)

3. Jointly developed by Apache, Sun and some companies and individuals

4. Deeply loved by Java enthusiasts, and recognized by some software developers

5. Web application server which is popular at present

Tomcat core components

Tomcat processing request process

1. The user enters the URL localhost:8080/test/index.jsp in the browser, and the request is sent to local port 8080, which is obtained by the Coyote HTTP/1.1 Connector listening there.

2.Connector hands the request to Engine (Container) of the Service where it is located and waits for a response from Engine

3.Engine gets the request localhost/test/index.jsp, which matches all virtual host Host

The 4.Engine matches a Host named localhost (even if it doesn't match, the request is handed over to the Host for processing, because the Host is defined as the default host for the Engine), and the Host named localhost gets the request / test/index.jsp, matching all the Context it owns. Host matches to Context with path / test (if not, the request is handed over to Context with path name "" to be processed)

5. The Context of path = "/ test" gets the request / index.jsp and finds the corresponding Servlet in its mapping table. Context matches to the Servlet whose URL Pattern is * .jsp, corresponding to the JspServlet class

6. Construct HttpServletRequest object and HttpServletResponse object, call doGet () or doPost () of JspServlet as parameters, execute business logic, data storage, etc.

7.Context returns the HttpServletResponse object after execution to Host

8.Host returns the HttpServletResponse object to Engine

9.Engine returns the HttpServletResponse object to Connector

10.Connector returns the HttpServletResponse object to the customer Browser.

Tomcat directory structure [root@localhost] # ll / usr/local/tomcat/ Total usage 124drwxr root-2 root root 4096 March 7 22:34 bin-rw-r- 1 root root 19203 February 5 00:32 BUILDING.txtdrwx- 3 root root 254 March 7 22:36 conf-rw-r- 1 root root 6095 February 5 00:32 CONTRIBUTING.mddrwxr-x--- 2 root root 4096 March 7 22 34 lib-rw-r- 1 root root 57092 February 5 00:32 LICENSEdrwxr-x--- 2 root root 197 March 7 22:36 logs-rw-r- 1 root root 2333 February 5 00:32 NOTICE-rw-r- 1 root root 3255 February 5 00:32 README.md-rw-r- 1 root root 6854 February 5 00:32 RELEASE-NOTES-rw-r- 1 root Root 16262 February 5 00:32 RUNNING.txtdrwxr-x--- 2 root root 30 March 7 22:34 tempdrwxr-x--- 7 root root 81 February 5 00:31 webappsdrwxr-x--- 3 root root 22 March 7 22:36 work -● bin stores script files for starting and shutting down Tomcat The more commonly used files are catalina.sh, startup.sh and shutdown.sh. ● conf stores various configuration files of the Tomcat server, and the more commonly used files are server.xml, context.xml, tomcat-users.xml and web.xml. ● lib stores the jar package of the Tomcat server and generally does not make any changes. Unless you connect to a third-party service, such as redis, you need to add the corresponding jar package ● logs to store Tomcat logs, ● temp, the directory where ● webapps stores project resources generated by Tomcat, and the working directory of ● workTomcat. Generally, Tomcat deployment steps are used when clearing Tomcat cache.

Step 1: download and share and install JDK through Windows

Jdk must be installed before deploying Tomcat, because jdk is a necessary environment for Tomcat to run.

[root@localhost ~] # smbclient-L / / 192.168.235.1 # remote sharing Sharename Type Comment-ADMIN$ Disk remote management tomcat Disk [root@localhost ~] # mkdir / abc [root@localhost ~] # mount.cifs / / 192.168.235. 1/tomcat / abc# mounts tomcat shared files to the Linux local directory [root@localhost ~] # cd / abc# enters the local directory to view [root@localhost abc] # ls12D18CFCD6599AFF0445766ACC4CA231C5025773.torrentapache-jmeter-5.1apache-jmeter-5.1.zipapache-tomcat-9.0.16.tar.gzjdk-11.0.5_windows-x64_bin.exejdk-8u152-windows-x64.exejdk-8u201-linux-x64.rpmtomcat optimized stress testing .jmx [root@localhost abc] # Rpm-ivh jdk-8u201-linux-x64.rpm # install JDK

Step 2: confirm the directory path of the JDK installation

[root@localhost ~] # cd / usr [root@localhost usr] # lsbin games java lib64 local share tmpetc include lib libexec sbin src# cut-in / usr directory see java directory [root@localhost usr] # cd java/ [root@localhost java] # lsdefault jdk1.8.0_201-amd64 latest# cut-in java directory jdk1.8.0_201-amd64 file [root@localhost java] # cd jdk1.8.0_201-amd64/ [root@localhost jdk1.8.0_201 -amd64] # pwd/usr/java/jdk1.8.0_201-amd64# confirm the installation path

Step 3: set the environment variable / etc/profile file

[root@localhost java] # vim / etc/profile# append three declaration entries to the last line of the file: export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64# declaration java working directory export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar# declaration location of java class file export PATH=$JAVA_HOME/bin:$PATH# declaration java environment variable [root@localhost java] # source / etc/profile# effective environment variable

Step 4: install and start the Tomcat service

[root@localhost java] # cd / abc [root@localhost abc] # tar zxvf apache-tomcat-9.0.16.tar.gz-C / usr/local/# extract the tomcat package to the / usr/local/ directory [root@localhost abc] # cd / usr/local/# cut into / usr/local/ directory to see apache-tomcat-9.0.16 [root@localhost local] # lsapache-tomcat-9.0.16 etc include lib64 sbin srcbin Games lib libexec share [root@localhost local] # mv apache-tomcat-9.0.16/ tomcat # rename the apache-tomcat-9.0.16 file to tomcat [root@localhost local] # lsbin games lib libexec share tomcatetc include lib64 sbin src [root@localhost local] # cd tomcat/bin/ # cut into the bin directory under the tomcat directory Here is the script to control the tomcat service [root@localhost bin] # lsbootstrap.jar configtest.sh shutdown.shcatalina.bat daemon.sh startup.batcatalina.sh digest.bat startup.shcatalina-tasks.xml digest.sh tomcat-juli.jarciphers.bat makebase.bat tomcat-native.tar. Gzciphers.sh makebase.sh tool-wrapper.batcommons-daemon.jar setclasspath.bat tool-wrapper.shcommons-daemon-native.tar.gz setclasspath.sh version.batconfigtest.bat shutdown.bat version.sh [root@localhost bin] # ln-s / usr/local/tomcat/bin/startup.sh / usr/bin/# create the soft link of the tomcat startup script to the system directory It is convenient for the system to identify [root@localhost bin] # ln-s / usr/local/tomcat/bin/shutdown.up.sh / usr/bin/# to create the soft link of the tomcat shutdown script to the system directory Make it easy for the system to identify [root@localhost bin] # startup.sh # start the tomcat service Using CATALINA_BASE: / usr/local/tomcatUsing CATALINA_HOME: / usr/local/tomcatUsing CATALINA_TMPDIR: / usr/local/tomcat/tempUsing JRE_HOME: / usr/java/jdk1.8.0_201-amd64Using CLASSPATH: / usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jarTomcat started . [root@localhost bin] # systemctl stop firewalld.service [root@localhost bin] # setenforce "disable firewall and enhanced security features [root@localhost bin] # netstat-ntap | grep 8080 to view the status of port 8080 of tomcat service tcp6 0:: 8080: * LISTEN 39596/java

Step 5: browse the default home page of Tomcat

Enter http: / / 192 in the browser. 168. 235. The web page can be accessed at 158: 8080

Step 6: optimize Tomcat startup time

[root@localhost bin] # vim / usr/java/jdk1.8.0_201-amd64/jre/lib/security/java.security# modifies java.security parameter securerandom.source=file:/dev/urandom# retrieves random parameter entry, and modifies random to urandom To shorten the startup time [root@localhost bin] # startup.sh # start the service Using CATALINA_BASE: / usr/local/tomcatUsing CATALINA_HOME: / usr/local/tomcatUsing CATALINA_TMPDIR: / usr/local/tomcat/tempUsing JRE_HOME: / usr/java/jdk1.8.0_201-amd64Using CLASSPATH: / usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli. JarTomcat started.Thank you.

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