系统环境:Centos7
1.下载tomcat8.5
- wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz
1 [root@localhost home]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz 2 --2019-09-18 13:25:16-- http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz 3 正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1 4 正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:80... 已连接。 5 已发出 HTTP 请求,正在等待回应... 200 OK 6 长度:9722154 (9.3M) [application/x-gzip] 7 正在保存至: “apache-tomcat-8.5.45.tar.gz” 8 9 100%[=======================================================================================================================================================================================================>] 9,722,154 14.9MB/s 用时 0.6s 10 11 2019-09-18 13:25:27 (14.9 MB/s) - 已保存 “apache-tomcat-8.5.45.tar.gz” [9722154/9722154])
2.解压
1 [root@localhost home]# tar -zxvf apache-tomcat-8.5.45.tar.gz 2 apache-tomcat-8.5.45/conf/ 3 …… 4 [root@localhost home]# ls -l 5 总用量 9496 6 drwxr-xr-x 9 root root 220 9月 18 13:26 apache-tomcat-8.5.45 7 -rw-r--r-- 1 root root 9722154 8月 15 06:46 apache-tomcat-8.5.45.tar.gz
3.运行
1 [root@localhost home]# cd apache-tomcat-8.5.45/bin 2 [root@localhost bin]# ./startup.sh 3 Using CATALINA_BASE: /home/apache-tomcat-8.5.45 4 Using CATALINA_HOME: /home/apache-tomcat-8.5.45 5 Using CATALINA_TMPDIR: /home/apache-tomcat-8.5.45/temp 6 Using JRE_HOME: /home/jdk/jre 7 Using CLASSPATH: /home/apache-tomcat-8.5.45/bin/bootstrap.jar:/home/apache-tomcat-8.5.45/bin/tomcat-juli.jar 8 Tomcat started.
浏览器访问:http://192.168.8.162:8080,tomcat安装成功
4.关闭tomcat
1 [root@localhost bin]# pwd 2 /home/apache-tomcat-8.5.45/bin 3 [root@localhost bin]# ./shutdown.sh 4 Using CATALINA_BASE: /home/apache-tomcat-8.5.45 5 Using CATALINA_HOME: /home/apache-tomcat-8.5.45 6 Using CATALINA_TMPDIR: /home/apache-tomcat-8.5.45/temp 7 Using JRE_HOME: /home/jdk/jre 8 Using CLASSPATH: /home/apache-tomcat-8.5.45/bin/bootstrap.jar:/home/apache-tomcat-8.5.45/bin/tomcat-juli.jar
5.修改tomcat端口号
修改conf文件下的server.xml,将port端口改成其他端口即可。
1 [root@localhost conf]# pwd 2 /home/apache-tomcat-8.5.45/conf 3 [root@localhost conf]# vi server.xml
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
6.tomcat发布服务
将需要发布的静态文件或者war包放在tomcat的webapps路径下,启动tomcat服务即可。
发布多个服务
server.xml配置文件中添加 <Context path="" docBase="/opt/tomcat/webapps/****"/>