浏览器访问 https://tomcat.apache.org/download-80.cgi 地址,选择 tomcat8 版本,下载 tar.gz 类型的安装包,地址如下:
https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.92/bin/apache-tomcat-8.5.92.tar.gz
使用 curl -O 命令下载,如下:
hxstrive@hxstrivedeMac ~ % sudo curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.92/bin/apache-tomcat-8.5.92.tar.gz Password: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0 curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.haxx.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.
提示下载失败,由于 HTTPS 证书错误导致,我们可以直接将下载地址的 https:// 改为 http:// 如下:
hxstrive@hxstrivedeMac ~ % sudo curl -O http://dlcdn.apache.org/tomcat/tomcat-8/v8.5.92/bin/apache-tomcat-8.5.92.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 10.2M 100 10.2M 0 0 16481 0 0:10:51 0:10:51 --:--:-- 22129 hxstrive@hxstrivedeMac ~ % ls Desktop Library Pictures jdk-8u351-macosx-x64.dmg Documents Movies Public Downloads Music apache-tomcat-8.5.92.tar.gz
使用 tar 命令解压安装包,如下:
hxstrive@hxstrivedeMac ~ % tar xvzf apache-tomcat-8.5.92.tar.gz x apache-tomcat-8.5.92/conf/ x apache-tomcat-8.5.92/conf/catalina.policy x apache-tomcat-8.5.92/conf/catalina.properties x apache-tomcat-8.5.92/conf/context.xml x apache-tomcat-8.5.92/conf/jaspic-providers.xml x apache-tomcat-8.5.92/conf/jaspic-providers.xsd x apache-tomcat-8.5.92/conf/logging.properties x apache-tomcat-8.5.92/conf/server.xml x apache-tomcat-8.5.92/conf/tomcat-users.xml x apache-tomcat-8.5.92/conf/tomcat-users.xsd x apache-tomcat-8.5.92/conf/web.xml x apache-tomcat-8.5.92/bin/ ...
运行 tomcat 的 startup.sh 命令启动 tomcat,如下:
hxstrive@hxstrivedeMac apache-tomcat-8.5.92 % ./bin/startup.sh ; tail -f logs/catalina.out Using CATALINA_BASE: /Users/hxstrive/apache-tomcat-8.5.92 Using CATALINA_HOME: /Users/hxstrive/apache-tomcat-8.5.92 Using CATALINA_TMPDIR: /Users/hxstrive/apache-tomcat-8.5.92/temp Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home Using CLASSPATH: /Users/hxstrive/apache-tomcat-8.5.92/bin/bootstrap.jar:/Users/hxstrive/apache-tomcat-8.5.92/bin/tomcat-juli.jar Using CATALINA_OPTS: Tomcat started. 22-Aug-2023 17:43:04.159 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/Users/hxstrive/apache-tomcat-8.5.92/webapps/ROOT] 22-Aug-2023 17:43:04.179 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/Users/hxstrive/apache-tomcat-8.5.92/webapps/ROOT]的部署已在[20]毫秒内完成 22-Aug-2023 17:43:04.180 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/Users/hxstrive/apache-tomcat-8.5.92/webapps/host-manager] 22-Aug-2023 17:43:04.205 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/Users/hxstrive/apache-tomcat-8.5.92/webapps/host-manager]的部署已在[24]毫秒内完成 22-Aug-2023 17:43:04.212 信息 [main] org.apache.coyote.AbstractProtocol.start 开始协议处理句柄["http-nio-8080"] 22-Aug-2023 17:43:04.843 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 24215 ms 22-Aug-2023 17:51:54.603 信息 [Thread-2] org.apache.coyote.AbstractProtocol.pause 暂停ProtocolHandler["http-nio-8080"] 22-Aug-2023 17:51:54.611 信息 [Thread-2] org.apache.catalina.core.StandardService.stopInternal 正在停止服务[Catalina] 22-Aug-2023 17:51:55.695 信息 [Thread-2] org.apache.coyote.AbstractProtocol.stop 正在停止ProtocolHandler ["http-nio-8080"] 22-Aug-2023 17:51:55.720 信息 [Thread-2] org.apache.coyote.AbstractProtocol.destroy 正在摧毁协议处理器 ["http-nio-8080"] 22-Aug-2023 17:57:54.889 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.服务器版本: Apache Tomcat/8.5.92 22-Aug-2023 17:57:54.906 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器构建: Aug 9 2023 11:22:56 UTC 22-Aug-2023 17:57:54.908 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器版本号: 8.5.92.0 22-Aug-2023 17:57:54.908 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 操作系统名称: Mac OS X 22-Aug-2023 17:57:54.909 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.版本: 10.15.5 22-Aug-2023 17:57:54.909 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 架构: x86_64 22-Aug-2023 17:57:54.910 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 环境变量: /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre 22-Aug-2023 17:57:54.911 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java虚拟机版本: 1.8.0_211-b12 22-Aug-2023 17:57:54.911 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.供应商: Oracle Corporation 22-Aug-2023 17:57:54.912 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /Users/hxstrive/apache-tomcat-8.5.92 22-Aug-2023 17:57:54.912 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /Users/hxstrive/apache-tomcat-8.5.92 22-Aug-2023 17:57:54.914 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.config.file=/Users/hxstrive/apache-tomcat-8.5.92/conf/logging.properties 22-Aug-2023 17:57:54.915 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 22-Aug-2023 17:57:54.916 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djdk.tls.ephemeralDHKeySize=2048 22-Aug-2023 17:57:54.916 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 22-Aug-2023 17:57:54.917 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 22-Aug-2023 17:57:54.917 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dignore.endorsed.dirs= 22-Aug-2023 17:57:54.922 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.base=/Users/hxstrive/apache-tomcat-8.5.92 22-Aug-2023 17:57:54.923 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.home=/Users/hxstrive/apache-tomcat-8.5.92 22-Aug-2023 17:57:54.924 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.io.tmpdir=/Users/hxstrive/apache-tomcat-8.5.92/temp 22-Aug-2023 17:57:54.924 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent 在java.library.path:[/Users/hxstrive/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]上找不到基于APR的Apache Tomcat本机库,该库允许在生产环境中获得最佳性能 22-Aug-2023 17:57:55.442 信息 [main] org.apache.coyote.AbstractProtocol.init 初始化协议处理器 ["http-nio-8080"] 22-Aug-2023 17:57:55.543 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1950 ms 22-Aug-2023 17:57:55.681 信息 [main] org.apache.catalina.core.StandardService.startInternal 正在启动服务[Catalina] 22-Aug-2023 17:57:55.682 信息 [main] org.apache.catalina.core.StandardEngine.startInternal 正在启动 Servlet 引擎:[Apache Tomcat/8.5.92] 22-Aug-2023 17:57:55.754 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/Users/hxstrive/apache-tomcat-8.5.92/webapps/docs] 22-Aug-2023 17:57:56.296 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/Users/hxstrive/apache-tomcat-8.5.92/webapps/docs]的部署已在[534]毫秒内完成 22-Aug-2023 17:57:56.298 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/Users/hxstrive/apache-tomcat-8.5.92/webapps/manager] 22-Aug-2023 17:57:56.417 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/Users/hxstrive/apache-tomcat-8.5.92/webapps/manager]的部署已在[120]毫秒内完成 22-Aug-2023 17:57:56.419 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/Users/hxstrive/apache-tomcat-8.5.92/webapps/examples] 22-Aug-2023 17:57:57.100 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/Users/hxstrive/apache-tomcat-8.5.92/webapps/examples]的部署已在[680]毫秒内完成 22-Aug-2023 17:57:57.102 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/Users/hxstrive/apache-tomcat-8.5.92/webapps/ROOT] 22-Aug-2023 17:57:57.130 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/Users/hxstrive/apache-tomcat-8.5.92/webapps/ROOT]的部署已在[28]毫秒内完成 22-Aug-2023 17:57:57.134 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/Users/hxstrive/apache-tomcat-8.5.92/webapps/host-manager] 22-Aug-2023 17:57:57.192 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[/Users/hxstrive/apache-tomcat-8.5.92/webapps/host-manager]的部署已在[58]毫秒内完成 22-Aug-2023 17:57:57.213 信息 [main] org.apache.coyote.AbstractProtocol.start 开始协议处理句柄["http-nio-8080"] 22-Aug-2023 17:57:57.283 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 1739 ms
到这里 Tomcat 就安装完成了。