如何SpringBoot项目部署到Centos虚拟机中
将SpringBoot项目部署到Centos虚拟机中
一、在IDEA中将项目打成Jar包
二、利用远程连接工具(Xshell,Xftp…)连接到Centos
可以看到项目已经启动成功…
三、在外部浏览器上测试部署是否成功
结果无法访问当前网址,我们试试在虚拟机中是否可以访问到?
四、在虚拟机中访问
可以正常访问。这是什么原因呢?
五、如何解决?
可能有些人已经猜到结果。
原因就是虚拟机里面的防火墙没有关闭,导致外网无法进行访问
那么如何关闭防火墙呢?只需要一行命令即可。> 看查防火墙状态:
sudo systemctl status firewalld
临时开关防火墙:重启电脑后又会恢复到默认的状
关闭防火墙:sudo systemctl stop firewalld
开启防火墙:sudo systemctl start firewalld
如果是想重启后防火墙还是处于关闭的状态,使用命令:
sudo systemctl disable firewalld
六、关闭防火墙后重新测试
SUCCESS!!!
好了,这篇文章就写到这里。
每天进步“亿点点”