Develop a habit, like first and then watch!!!
table of Contents
1 Introduction
I have configured Tomcat on Alibaba Cloud before, and I tested it at the time and it was accessible. After that, I uninstalled Tomcat for some reasons. I started to reinstall Tomcat to start the test last night. I found that it was always inaccessible. I have no time for a night, mainly due to the following reasons, I hope it will help you
2. Scheme
Alibaba Cloud's inspection measures are two layers, the first layer is the firewall, and the second layer is the security group. Here we first configure the firewall
2.1 Configure firewall and open ports
Here we first check whether the status of the firewall is open
systemctl status firewalld
``
如果出现这个错误 `Unit firewalld.service could not be found.` 就说明我们没有防火墙的服务,我们需要先下载防火墙;
```java
yum install firewalld firewall-config
After the download is over, we need to start the firewall first:
service firewalld start
After the startup is complete, we will open the 8080 port of Tomcat
firewall-cmd --zone=public --permanent --add-port=8080/tcp
After opening the port, we need to refresh the effect again, which can be achieved by the following command:
firewall-cmd --reload
After refreshing again, we use the following command to view the opened port number:
firewall-cmd --list-all
If you see the following interface, it means that the firewall has opened the following ports
2.2 Configure Security Group in Alibaba Cloud Console
It should be noted here that it is best to configure both the incoming and outgoing directions of port 8080, so that the security group has also been configured.
2.3 Check ports and resolve port conflicts
At this time we go to start Tomcat, here we enter the bin directory of Tomcat to start Tomcat with the following command
./startup.sh
Best not to use the sh startup.sh
command to start the Tomcat
this time if your port does not conflict, then you will be able to visit you 阿里云ip:8080
, you should be able to see Tomcat page, but if you do not see, basically it means port conflicts, and this time We need to check the port to see which port is in conflict. At this time, we need to check the log, usually under such a path.
By vi 日志名
entering and viewing,
we see an error similar to this
org.apache.catalina.core.StandardServer.await StandardServer.await: create[localhost:8106]:
It means that the port has conflicted and the port number needs to be modified.
After that, we need to enter conf/server.xml to modify and find the corresponding port number.
The main reason is that the port numbers in these several places may conflict:
modify the port according to your actual situation, and start Tomcat without modifying it once. If the port error is not reported, then Tomcat can start normally
In this way, my cute Tom cat finally came out, thank goodness. The
code word is not easy, if you think it is helpful to you, you can follow my official account, the newcomer up needs your support!!!