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 deployment installation

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

Share

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

Tomcat introduction

■ free, open source Web application server

A core project of the ■ Apache Software Foundation (Apache Software Foundation) Jakarta project

■ is jointly developed by Apache, Sun and some companies and individuals.

■ is deeply loved by Java enthusiasts and recognized by some software developers.

■ 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 dosage 124

Drwxr-x--- 2 root root 4096 March 7 22:34 bin

-rw-r- 1 root root 19203 February 5 00:32 BUILDING.txt

Drwx- 3 root root 254 March 7 22:36 conf

-rw-r- 1 root root 6095 February 5 00:32 CONTRIBUTING.md

Drwxr-x--- 2 root root 4096 March 7 22:34 lib

-rw-r- 1 root root 57092 February 5 00:32 LICENSE

Drwxr-x--- 2 root root 7 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.txt

Drwxr-x--- 2 root root 30 March 7 22:34 temp

Drwxr-x--- 7 root root 81 February 5 00:31 webapps

Drwxr-x--- 3 root root 22 March 7 22:36 work

● bin

Store the script files for starting and shutting down Tomcat, the more commonly used are catalina.sh, startup.sh,

Three files of shutdown.sh

● conf

To store various configuration files of Tomcat server, the most commonly used ones are server.xml, context.xml,

Tomcat-users.xml, web.xml four files.

● lib

The jar package that holds the Tomcat server is generally unchanged unless you connect to a third-party service, such as redis

Then you need to add the corresponding jar package.

● logs

Store Tomcat logs

● temp

Store the files generated by the Tomcat runtime

● webapps

Directory where project resources are stored

● work

Tomcat working directory, which is usually used when clearing the Tomcat cache

Tomcat deployment steps

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

# Mount tomcat shared files to Linux local directory

[root@localhost ~] # cd / abc # enter the local directory for viewing

[root@localhost abc] # ls

12D18CFCD6599AFF0445766ACC4CA231C5025773.torrent

Apache-jmeter-5.1

Apache-jmeter-5.1.zip

Apache-tomcat-9.0.16.tar.gz

Jdk-11.0.5_windows-x64_bin.exe

Jdk-8u152-windows-x64.exe

Jdk-8u201-linux-x64.rpm

Tomcat optimized pressure test. 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] # ls

Bin games java lib64 local share tmp

Etc include lib libexec sbin src

# cut into the / usr directory and see java directory

[root@localhost usr] # cd java/

[root@localhost java] # ls

Default jdk1.8.0_201-amd64 latest

# cut into the java directory to see the 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

# declare the working directory of java

Export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar

# declare the location of the java class file

Export PATH=$JAVA_HOME/bin:$PATH

# declare java environment variable

[root@localhost java] # source / etc/profile

# effective environment variables

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 the tomcat package to the / usr/local/ directory

[root@localhost abc] # cd / usr/local/ # cut into the / usr/local/ directory to see apache-tomcat-9.0.16

[root@localhost local] # ls

Apache-tomcat-9.0.16 etc include lib64 sbin src

Bin games lib libexec share

[root@localhost local] # mv apache-tomcat-9.0.16/ tomcat # rename apache-tomcat-9.0.16 file to tomcat

[root@localhost local] # ls

Bin games lib libexec share tomcat

Etc include lib64 sbin src

[root@localhost local] # cd tomcat/bin/ # cut into the bin directory under the tomcat directory, where there are scripts to control the tomcat service

[root@localhost bin] # ls

Bootstrap.jar configtest.sh shutdown.sh

Catalina.bat daemon.sh startup.bat

Catalina.sh digest.bat startup.sh

Catalina-tasks.xml digest.sh tomcat-juli.jar

Ciphers.bat makebase.bat tomcat-native.tar.gz

Ciphers.sh makebase.sh tool-wrapper.bat

Commons-daemon.jar setclasspath.bat tool-wrapper.sh

Commons-daemon-native.tar.gz setclasspath.sh version.bat

Configtest.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 to facilitate system identification

[root@localhost bin] # ln-s / usr/local/tomcat/bin/shutdown.up.sh / usr/bin/

# create the soft link of the tomcat shutdown script to the system directory to facilitate system identification

[root@localhost bin] # startup.sh # start the tomcat service

Using CATALINA_BASE: / usr/local/tomcat

Using CATALINA_HOME: / usr/local/tomcat

Using CATALINA_TMPDIR: / usr/local/tomcat/temp

Using JRE_HOME: / usr/java/jdk1.8.0_201-amd64

Using CLASSPATH: / usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.

[root@localhost bin] # systemctl stop firewalld.service

[root@localhost bin] # setenforce 0

# turn off firewall and enhanced security features

[root@localhost bin] # netstat-ntap | grep 8080 to view port 8080 status of tomcat service

Tcp6 0 0: 8080: * LISTEN 39596/java

Step 5: browse the default home page of Tomcat

Enter http://192.168.235.158:8080 in the browser 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 parameters

Securerandom.source=file:/dev/urandom

# retrieve the random parameter entry and change random to urandom to shorten the startup time

[root@localhost bin] # startup.sh # start the service in an instant

Using CATALINA_BASE: / usr/local/tomcat

Using CATALINA_HOME: / usr/local/tomcat

Using CATALINA_TMPDIR: / usr/local/tomcat/temp

Using JRE_HOME: / usr/java/jdk1.8.0_201-amd64

Using CLASSPATH: / usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat 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