Linux操作系统CentOS7安装Tomcat

参考文档

官网下载Tomcat

官网地址

wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz

解压使用

tar -zxvf apache-tomcat-9.0.65.tar.gz

启动

没有JDK环境,启动会报错

cd apache-tomcat-9.0.65
bin/startup.sh

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

安装JDK

yum search java|grep jdk
#选择一个版本安装
yum install -y java-1.8.0-openjdk

再次启动Tomcat

bin/startup.sh

Using CATALINA_BASE:   /root/apache-tomcat-9.0.65
Using CATALINA_HOME:   /root/apache-tomcat-9.0.65
Using CATALINA_TMPDIR: /root/apache-tomcat-9.0.65/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /root/apache-tomcat-9.0.65/bin/bootstrap.jar:/root/apache-tomcat-9.0.65/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.

防火墙修改

  • linux防火区命令
# 查看firewall服务状态
systemctl status firewalld

# 开启、重启、关闭 firewall.service服务
# 开启
service firewalld start

# 重启
service firewalld restart

# 关闭
service firewalld stop

# 查看防火墙规则
firewall-cmd --list-all     # 查看全部信息
firewall-cmd --list-ports   # 只看端口信息

# 开启端口
firewall-cmd --zone=public --add-port=80/tcp --permanent        # 开启防火墙端口80
firewall-cmd --zone=public --remove-port=8080/tcp --permanent   #  关闭防火墙端口8080 
systemctl restart firewalld.service     # 重启防火墙命令

命令含义:
--zone                  # 作用域
--add-port=80/tcp       # 添加端口,格式为:端口号/通讯协议
--permanent             # 永久生效,没有此参数重启后失效

端口修改

将此处的8080修改为80端口

vi conf/server.xml
#将8080替换为80

重启Tomacat

  • 关闭
bin/shutdown.sh
Using CATALINA_BASE:   /root/apache-tomcat-9.0.65
Using CATALINA_HOME:   /root/apache-tomcat-9.0.65
Using CATALINA_TMPDIR: /root/apache-tomcat-9.0.65/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /root/apache-tomcat-9.0.65/bin/bootstrap.jar:/root/apache-tomcat-9.0.65/bin/tomcat-juli.jar
Using CATALINA_OPTS:
  • 启动
Using CATALINA_BASE:   /root/apache-tomcat-9.0.65
Using CATALINA_HOME:   /root/apache-tomcat-9.0.65
Using CATALINA_TMPDIR: /root/apache-tomcat-9.0.65/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /root/apache-tomcat-9.0.65/bin/bootstrap.jar:/root/apache-tomcat-9.0.65/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.

你可能感兴趣的:(Linux操作系统CentOS7安装Tomcat)