0.下载解压安装包
1 2
   | wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.31/bin/apache-tomcat-9.0.31.tar.gz tar -zxvf apache-tomcat-9.0.31.tar.gz
   | 
 
1.将解压好的文件夹拷贝到指定位置并启动
1 2 3
   | mv apache-tomcat-9.0.31 /usr/local/tomcat cd /usr/local/tomcat/apache-tomcat-9.0.31/bin ./startup.sh
   | 
 
2.检查是否安装成功。
浏览器查看http://localhost:8080
或者在终端中输入
1 2 3 4 5 6 7 8 9 10 11 12 13 14
   | $~ curl 127.0.0.1:8080
  <!DOCTYPE html> <html lang="en">     <head>         <meta charset="UTF-8" />         <title>Apache Tomcat/9.0.34</title> ----- 中间省略 -----     </body> </html>
  curl: (7) Failed to connect to 127.0.0.1 port 8080: 拒绝连接
   | 
 
3.编写快速启动脚本
创建
1 2 3
   | cd /etc/rc.d/init.d/ touch tomcat chmod +x tomcat
   | 
 
编辑文件
1 2 3 4 5 6 7 8 9 10 11 12 13
   | vim tomcat
 
 
 
 
 
  TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-9.0.31 case $1 in start) su root $TOMCAT_HOME/bin/startup.sh;; stop) su root $TOMCAT_HOME/bin/shutdown.sh;; *) echo "require start|stop" ;; esac
   | 
 
Tomcat快捷启动命令
1 2
   | service tomcat start service tomcat stop
   | 
 
4.开机自启动
1 2
   | chkconfig --add tomcat chkconfig tomcat on
   |