Linux系统上安装Tomcat

     lz今天在Linux系统上安装了tomcat,就总结了下来,希望能帮到大家。

1.从官网下载Liunx版本的tomcat,链接:http://tomcat.apache.org/


2.通过xftp把tomcat的安装包传到Linux服务器上,lz传到了/opt/tomcat下

3.安装包上传到服务器上后,通过命令tar -zxvf apache-tomcat-8.5.30.tar.gz 解压安装包,解压后里面文件如下所示:


4.进入bin文件下,执行 ./startup.sh命令启动tomcat

扫描二维码关注公众号,回复: 1030750 查看本文章

5.启动完后,我们访问tomcat的地址 ip:8080  ip通过 ifconfig查看

lz发现访问超时,如下图


 lz遇到上面的情况也有点蒙,不知道啥情况,就上网查,网上说需要开放端口和关闭防火墙,但是CentOS-7没有iptables-services,而是采用systemd。所以lz就尝试关闭systemd,并且下载iptables-services服务。


检测是否开启了 firewalled.service  命令:systemctl status firewalld.service


发现Linux服务器开启了firewalld.service,所以要关闭,通过命令 systemctl stop firewalld.service 来关闭,并且通过命令

systemctl disable firewalld.service 来禁止开机自启动服务。

因为CentOS-7没有配置iptables-services服务,通过 yum install iptables-services 来下载iptables-services服务。下载完成后,通过vim /etc/sysconfig/iptables 在后面加上

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT  来开放8080端口

通过 service iptables stop 关闭防火

chkconfig iptables off 永久关闭防火墙

再次访问tomcat



发现访问成功,至此在Linux系统上tomcat安装完成了。



猜你喜欢

转载自blog.csdn.net/dam454450872/article/details/79955195