阿里云添加端口(tomcat,mysql,redis等)
网上很多都说要配置安全组,其实这个只说了一半,系统内也要在防火墙中加端口,本文用的centos的系统,以tomcat的8080端口为栗子。
前提条件:1.tomcat正常启动; 2.外界能ping的通阿里云服务器; 3.curl http://localhost:8080能正常得到结果
一.系统内添加端口
- 编辑防火墙文件
vim /etc/sysconfig/iptables
- 添加端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
- 重启防火墙(centos7用systemctl,centos6用service)
systemctl restart iptables.service
或
service iptables restart
二.阿里云安全组放开端口
到阿里云控制台,添加了8080安全组规则(这个不会的自己去网上看吧)