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

Installation and deployment of Tomcat services (theory and practice)

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

Share

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

Tomcat introduces the free, open source Web application server Apache Software Foundation (Apache Software Foundation) one of the core projects in the Jakarta project is developed by Apache, Sun and a number of companies and individuals, which is deeply loved by Java enthusiasts, and has been recognized by some software developers. Tomcat core components of the popular Web application server

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 the Engine (Container) of the Service where it is located, and waits for the response from Engine; 3.Engine gets the request localhost/test/index.jsp, which matches all virtual hosts 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. The Host matches to the Context with the path / test (if there is no match, the request is handed over to the Context with the path name ""); 5. The Context with 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 to execute business logic, data storage, etc.; 7.Context returns the HttpServletResponse object after execution to Host;8.Host, HttpServletResponse object to Engine;9.Engine, HttpServletResponse object to Connector;10.Connector, HttpServletResponse object to 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, when clearing Tomcat cache, you will use Tomcat deployment step 1: download and share 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 JDK installation [root@localhost] # cd / usr [root@localhost usr] # lsbin games java lib64 local share tmpetc include lib libexec sbin src# cut into / usr directory see java directory [root@localhost usr] # cd java/ [root@localhost java] # lsdefault jdk1.8.0_201-amd64 latest# cut into java directory to see jdk1.8.0_201-amd64 text [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 export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64# to the last line of the file Declare java's working directory export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar# affirms the location of java class files export PATH=$JAVA_HOME/bin:$PATH# declares java environment variable [root@localhost java] # source / etc/profile# valid 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/# unzip tomcat package to / 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 # change The name apache-tomcat-9.0.16 file is 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.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 the tomcat service tcp6 0:: 8080: * LISTEN 39596/java step 5: browse the default home page of Tomcat in the browser Enter http://192.168.2355.158:8080 to access the web page

Step 6: optimize Tomcat startup time [root@localhost bin] # vim / usr/java/jdk1.8.0_201-amd64/jre/lib/security/java.security# modify java.security parameter securerandom.source=file:/dev/urandom# retrieve random parameter entry, modify 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 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.

Share To

Servers

Wechat

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

12
Report