Install TomCat service
1. Install the JDK environment
https://www.oracle.com/java/technologies/downloads/ official website for download
wget https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.deb (sha256)
When using dpkg for software installation, it prompts: dpkg: error processing package XXX: dependency problem, still not configured
Use the following command, sudo apt-get install -f command to repair package dependencies
After the analysis, re-use dpkg –i XXX.deb, that's it.
Path to jdk installation:
/usr/lib/jvm/jdk-20
sudo ln -s /usr/lib/jvm/jdk-20 /exprot/server/jdk
create environment variables
sudo vim /etc/profile # system level
soruce /etc/profile # Take effect immediately
Check if jdk is installed successfully
2. Unzip and install tomcat
Because tomcat provides web services, it is vulnerable to hacker attacks. For server security, it is recommended that non-root users deploy
(1), close the firewall
(2), and create users
sudo useradd tomcat -m # -m comes with creating tomcat plus directory
cat /etc/passwd # View user information
sudo passwd tomcat # Create user password
(3), download tomcat
Download address https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.11/bin/apache-tomcat-10.1.11.tar.gz
sudo wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.11/bin/apache-tomcat-10.1.11.tar.gz
If you are prompted with a certificate question, add --no-check-certificate to not verify the certificate
sudo wget --no-check-certificate https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.11/bin/apache-tomcat-10.1.11.tar.gz
(4) Decompression, soft link
sudo tar -zxvf apache-tomcat-10.1.11
(5) Modify the permissions of the tomcat installation directory
sudo chown -R tomcat:tomcat /export/server/ tomcat # Modify the soft link and tomcat installation file at the same time, use *tomcat* to match
start tomcat
./startup.sh
Check whether the tomcat service is normal
curl 127.0.0.1:8080 # If there is a range of html strings in the request through curl, it means success. If the above picture does not appear in the local test (the local machine installed with mysql), it means that the
non-local access is unsuccessful, and the port 8080 is restricted. Tomcat default port is 8080
Ubuntu default is to turn off the firewall
sudo ufw status # Check the firewall status active turn on inactive turn off
sudo ufw enable # turn on the firewall
sduo ufw disable # turn off the firewall
Centos default is to open the firewall
systemctl stop firewalld # close the firewall
systemctl disable firewalld # stop the firewall from booting#Method 2 Allow external access to port 8080
firewall-cmd --add-port=8080/tcp --permanent # permanent permanent effect
firewall-cmd --reload # Reload the firewall rules to make them take effect