Java project online cloud server environment (2) - Tomcat installation and configuration

Java project online cloud server environment (2) - Tomcat installation and configuration

Tomcat choice:

It is best to choose the cloud server tomcat consistent with the tomcat version number running on the local project to avoid unnecessary problems.

Configuration steps:

1. First enter the cloud server to create a folder where tomcat is placed. Here, Xftp can be used on Windows systems and Transmit can be used on macOS systems to directly create new files. For example: /usr/local/tomcat

2. If you use the command line to create a new folder, do the following:

cd /usr/local
mkdir tomcat

3. Upload the downloaded tomcat package to the server /usr/local/tomcat (if you upload via ftp, go directly to the fourth step)

scp 本地文件绝对路径 [email protected]服务器IP地址:需要传入到服务的哪个文件下的绝对路径

4. Unzip the compressed package:

tar -zxvf apache-tomcat-9.0.55.tar.gz

5. Enter the bin directory of the unzipped folder:

cd /usr/local/tomcat/apache-tomcat-9.0.55/bin

6. Start the tomcat service:

./startup.sh

7. Stop the tomcat service:

./shutdown.sh

8. After starting the tomcat service, log in to the Alibaba Cloud official website, enter the ECS server console and find the network and security configuration security group:

Insert image description here

9. Find the management rules, add the port manually, and add the corresponding port number according to the needs of your project:

Insert image description here
Insert image description here

10. Return to the tomcat configuration and check whether the firewall status is on:

systemctl status firewalld

11. If this error occurs, Unit firewalld.service could not be found.it means that we do not have a firewall service. We need to download the firewall first:

yum install firewalld firewall-config

12. After downloading, start the firewall:

service firewalld start

13. The following are commonly used commands for firewalls:

启动防火墙:systemctl start firewalld
禁用防火墙:systemctl stop firewalld
重启防火墙:firewall-cmd --reload
查看防火墙状态:systemctl status firewalld

14. After starting the firewall, open the corresponding port number:

firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --zone=public --permanent --add-port=8083/tcp
firewall-cmd --zone=public --permanent --add-port=3306/tcp

15. Refresh effect:

firewall-cmd --reload

16. Check the opened port number:

firewall-cmd --list-all

17. Restart the tomcat service:

./shutdown.sh
./startup.sh

18. Enter the IP of your server: 8080 to enter the tomcat page. At this time, tomcat is configured.

Insert image description here

Guess you like

Origin blog.csdn.net/Turniper/article/details/130320167