说明:安装路径可以自行修改;本文适合小白傻瓜式安装。
一、下载tomcat9
1.1 官网下载
Tomcat官网下载对应版本的tar.gz文件,然后上传到linux服务器。
1.2 wget下载
地址不能使用的话自己重新找个地址。
wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-9/v9.0.0.M9/bin/apache-tomcat-9.0.0.M9.tar.gz
二、解压
- 用tar命令解压后,会生成apache-tomcat-9.0.0.M9目录;
- 把apache-tomcat-9.0.0.M9移动到/usr/local目录下
tar -zxvf apache-tomcat-9.0.27.tar.gz
mv apache-tomcat-9.0.27 /usr/local
三、Tomcat服务相关
1、进入解压目录的bin文件夹,运行命令./startup.sh
./startup.sh
会自动输出下面内容:
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.27
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.27
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.27/temp
Using JRE_HOME: /usr/local/jdk1.8/jre
Using CLASSPATH: /usr/local/apache-tomcat-9.0.27/bin/bootstrap.jar:/usr/local/apache-tomcat-9.0.27/bin/tomcat-juli.jar
2、验证是否成功开启
在浏览器输入http://127.0.0.1:8080 ,或者使用命令w3m http://127.0.0.1:8080(w3m命令没有的话,请使用apt-get或者yum安装,具体请百度)
w3m http://127.0.0.1:8080
3、关闭服务
进入解压目录的bin文件夹,运行命令./shutdowm.sh
./shutdowm.sh
会自动输出下面内容:
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.27
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.27
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.27/temp
Using JRE_HOME: /usr/local/jdk1.8/jre
Using CLASSPATH: /usr/local/apache-tomcat-9.0.27/bin/bootstrap.jar:/usr/local/apache-tomcat-9.0.27/bin/tomcat-juli.jar
4、查看tomcat版本
进入解压目录的bin文件夹,运行命令./version.sh
./version.sh
会自动输出下面内容:
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.27
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.27
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.27/temp
Using JRE_HOME: /usr/local/jdk1.8/jre
Using CLASSPATH: /usr/local/apache-tomcat-9.0.27/bin/bootstrap.jar:/usr/local/apache-tomcat-9.0.27/bin/tomcat-juli.jar
Server version: Apache Tomcat/9.0.27
Server built: Oct 7 2019 09:57:22 UTC
Server number: 9.0.27.0
OS Name: Linux
OS Version: 3.10.0-957.21.3.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_131-b11
JVM Vendor: Oracle Corporation
来源:oschina
链接:https://my.oschina.net/u/4540973/blog/4503488