前言
- 生产环境无法联网,只能通过下载离线版本更新Tomcat到小版本最新
- 注意Tomcat10和11与jdk1.8都不兼容,只能更新到小版本的最新
- 前提是按照我这种方法配置Tomcat开机自启的https://blog.csdn.net/qq_44648936/article/details/130022136
步骤
- 备份整个安装目录和配置文件,压缩也好,文件复制也好,或者干脆就不删除,虚拟机上留两份Tomcat
- 从官网下载tomcat的压缩包:https://tomcat.apache.org/download-90.cgi
- 通过xshell或moberxterm连接虚拟机,并将压缩包上传到虚拟机内
- 使用命令解压:
tar xvf apache-tomcat-9.0.78.tar.gz
- 关闭原先的Tomcat服务:
systemctl stop tomcat
- 修改环境变量的配置文件:
vi /etc/profile
#修改旧地址
#CATALINA_HOME=/home/evsoft/tomcat/apache-tomcat-9.0.68
#CATALINA_BASE=/home/evsoft/tomcat/apache-tomcat-9.0.68
#PATH=$PATH:$CATALINA_BASE/bin
CATALINA_HOME=/home/evsoft/tomcat/apache-tomcat-9.0.78
CATALINA_BASE=/home/evsoft/tomcat/apache-tomcat-9.0.78
PATH=$PATH:$CATALINA_BASE/bin
- 修改新的Tomcat的配置文件conf/server.xml,保证端口和原先的一致
- 将项目jdk或war包等放入webapps中,或直接复制:
cp -r auto-publish-project/ /home/evsoft/tomcat/apache-tomcat-9.0.78/webapps/auto-publish-project
若不设置开机自启,则直接startup.sh启动就可以去验证是否启动成功了
- 设置Tomcat开机自启:
vi /etc/systemd/system/tomcat.service
# 主要是修改启动和关闭文件的地址
[Unit]
#Description=Tomcat9068
Description=Tomcat9078
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=oneshot
#ExecStart=/home/evsoft/tomcat/apache-tomcat-9.0.68/bin/startup.sh
#ExecStop=/home/evsoft/tomcat/apache-tomcat-9.0.68/bin/shutdown.sh
ExecStart=/home/evsoft/tomcat/apache-tomcat-9.0.78/bin/startup.sh
ExecStop=/home/evsoft/tomcat/apache-tomcat-9.0.78/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
- 编辑目录:
vi /home/evsoft/tomcat/apache-tomcat-11.0.0-M9/bin/setclasspath.sh
,在如下位置配置Tomcat的jdk:export JAVA_HOME=/usr/local/jdk1.8
- 重新载入配置文件:
systemctl daemon-reload
- 启动tomcat服务:
systemctl start tomcat.service
- 查看tomcat服务状态:
systemctl status tomcat.service
参考
- https://blog.csdn.net/qq_44648936/article/details/130022136