Centos installation and deployment of Tomcat (10.1) step-by-step tutorial

 

It is recommended to use a non-Root user to install and start Tomcat

You can create a user: tomcat for deployment

 1. Download the Tomcat compressed package

Download the corresponding compressed package locally from the Tomcat official website. The download here is version 10.1.

Download link: https://tomcat.apache.org/download-10.cgi

 2. Install Tomcat

The installation of Tomcat10.1 depends on the JDK11 and above version environment, so you need to check whether the system has JDK installed and the JDK version.

java -version

 

 Friends who have not installed JDK or whose JDK version is insufficient, please move to this blog:

http://t.csdn.cn/bRfCR

1. Operate as root user and create tomcat user

# Switch to the root user and enter the password

su root

# Use the root user to operate
useradd tomcat
# Optional, configure the password for the tomcat user
passwd tomcat

2. Unzip the Tomcat installation package

The folder /export/server was created when installing the JDK environment. This folder is used to install and deploy JDK and Tomcat. If this folder has not been created, please create it first.

mkdir -p /export/server

# Use the root user to operate, otherwise you will not have permission to decompress to /export/server unless you modify the permissions of this folder
tar -zxvf apache-tomcat-10.1.11.tar.gz -C /export/server

3. Create Tomcat soft link

Switch to the /export/server folder and view the folder

 cd /export/server/

 ls -l

 There is an apache-tomcat-10.1.11 file in the folder, establish a soft connection

# Use root user to operate
ln -s /export/server/apache-tomcat-10.1.11/ /export/server/tomcat

 

4. Modify the permissions of the tomcat installation directory

# Use the root user to modify the soft link and tomcat installation folder at the same time
chown -R tomcat:tomcat /export/server/tomcat

chown -R tomcat:tomcat apache-tomcat-10.1.11

 

 At this time, the user group permissions have been modified

5. Switch to tomcat user

su - tomcat

3. Start tomcat  

 Enter the following command, and Tomcat started. appears , indicating that the startup is successful.

/export/server/tomcat/bin/startup.sh

 

1. Tomcat starts on port 8080. You can check whether it starts normally and successfully.

netstat -anp | grip 8080

 

 

4. Add firewall rules

The CentOS system has a firewall enabled by default to prevent external network traffic from accessing the system.

Therefore, if you want Tomcat to work normally, you need to release the 8080 port used by Tomcat by default.

There are two ways to release:

  1. Turn off firewall

  2. Configure firewall rules and allow ports

 

# Choose one of the following 2 operations
# Method 1: Turn off the firewall
systemctl stop firewalld         # Turn off the firewall
systemctl disable firewalld         # Stop the firewall from starting at boot

# Method 2: Allow external access to port 8080
firewall-cmd --add-port=8080/tcp --permanent         # --add-port=8080/tcp means to allow TCP access to port 8080, --permanent means permanent
firewall -cmd --reload                                # Reload the firewall rules to take effect

For the sake of convenience, if it is only used for learning, it is recommended to choose method 1 and directly turn off the firewall once and for all.  

 

 

5. Test whether Tomcat is installed successfully 

Open your browser and enter:

http://hostname:8080

or

http://your IP address:8080

The following page appears indicating that Tomcat is successfully installed. 

 

 

Guess you like

Origin blog.csdn.net/2301_77160836/article/details/131686729