1.将下载好的安装包上传至linux服务器
2.解压
tar -zxvf apache-tomcat-8.5.50.tar.gz
3.解压后进入bin目录
4.启动
./startup.sh
5.访问:http://IP:8080/
6.设置开机自启,在/etc/init.d下新建一个文件tomcat
vi /etc/init.d/tomcat
7.然后点击"i"写下如下代码,tomcat自启动脚本,保存退出
#!/bin/sh -e
# chkconfig: 345 99 10
### BEGIN TOMCAT SERVICE
### END INIT INFO
export JAVA_HOME=/opt/java/jdk1.8.0_221/ #根据自己的路径配置
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.
export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.50/ #根据自己的路径配置
case "$1" in
start)
${CATALINA_HOME}/bin/startup.sh
exit 0
;;
stop)
${CATALINA_HOME}/bin/shutdown.sh
exit 0
;;
debug)
${CATALINA_HOME}/bin/shutdown.sh
${CATALINA_HOME}/bin/catalina.sh run
exit 0
;;
force-reload|restart)
${CATALINA_HOME}/bin/startup.sh
${CATALINA_HOME}/bin/shutdown.sh
exit 0
;;
*)
echo "Usage: /etc/init.d/tomcat {start|stop|restart|force-reload|debug}"
exit 1
;;
esac
exit 0
8.设置权限
chmod +x /etc/init.d/tomcat
9.设定开机启动服务
sudo chkconfig tomcat on
10.重启服务器,访问地址第5步的地址