Linux服务器上部署Tomcat测试环境

时间:2022-03-23 07:20:11

部署Tomcat网站测试环境

  1. MobaXterm SSH连上终端服务器
  2. 下载jdk并配置java环境
  3. 下载tomcat

wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz

并解压到当前目录下:tar zxvf apache-tomcat-7.0.92.tar.gz

4.照文Tomcat 部署项目的三种方法第一种方法部署,将jeesite.war放入tomcatwebapps目录。

5.由于tomcat默认端口8080,照文无法访问部署在linux上的Tomcat服务器解决方案查看防火墙规则:

iptables -L --line-number

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination

1    ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED

2    ACCEPT     icmp --  anywhere             anywhere

3    ACCEPT     all  --  anywhere             anywhere

4    ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh

5    REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

 

Chain FORWARD (policy ACCEPT)

num  target     prot opt source               destination

1    REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

 

Chain OUTPUT (policy ACCEPT)

num  target     prot opt source               destination

需要开放8080端口:

iptables -I INPUT 5 -m  state  --state  NEW  -m  tcp  -p  tcp  --dport  8080  -j  ACCEPT

6.进入tomcat bin目录启动服务器:sh startup.sh

启动时可查看日志:tailf apache-tomcat-7.0.92/logs/catalina.out

部署时若报错:RROR [net.sf.ehcache.Cache] - Unable to set localhost. This prevents creation of a GUID. Cause was: Centos10:

需要找到/etc/hosts,将Centos10加入,如下所示:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 Centos10

更新网站

  1. MobaXterm SSH连上终端服务器
  2. 进入tomcat bin目录关闭服务器:sh shutdown.sh
  3. 删除tomcatwebapps目录中的jeesite文件夹
  4. 将更新的jeesite.war放入tomcatwebapps目录
  5. 进入tomcat bin目录开启服务器:sh startup.sh