Linux Ubuntu installation common services (2) Tomcat

Install TomCat service

1. Install the JDK environment

insert image description here

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)
insert image description here

insert image description here
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.

insert image description here

Path to jdk installation:

/usr/lib/jvm/jdk-20
insert image description here
sudo ln -s /usr/lib/jvm/jdk-20 /exprot/server/jdk
insert image description here
create environment variables
sudo vim /etc/profile # system level
insert image description here

insert image description here

soruce /etc/profile # Take effect immediately

insert image description here

Check if jdk is installed successfully
insert image description here

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
insert image description here
insert image description here

insert image description here

(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
insert image description here
(4) Decompression, soft link

sudo tar -zxvf apache-tomcat-10.1.11
insert image description here
insert image description here

(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
insert image description here
insert image description here
insert image description here

insert image description here

start tomcat

./startup.sh
insert image description here

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
insert image description here
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

insert image description here

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

Guess you like

Origin blog.csdn.net/u013400314/article/details/132038716