ChatGPT 可用网址,仅供交流学习使用,如对您有所帮助,请收藏并推荐给需要的朋友。
https://ckai.xyz
@TOC
一、tomcat介绍
1.tomcat简介
Tomcat是一个开源、免费的Web服务器,属于轻量级web服务器,适合部署中小型、并发访问用户不是很多的web项目,是部署中小型jsp的首选。
2.tomcat官网
tomcat软件官网下载:https://tomcat.apache.org/download-80.cgi
二、本次环境规划
本次环境规划介绍
hostname | IP地址 | 操作系统版本 | tomcat版本 | java版本 |
---|---|---|---|---|
docker | 192.168.3.157 | centos 7.6 | 10.1.7.0 | 11.0.18 |
三、安装jdk
1.下载jdk包
下载地址:https://www.oracle.com/java/technologies/downloads/#java11
[root@docker tomcat]# ls
apache-tomcat-10.1.7.tar.gz jdk-11.0.18_linux-x64_bin.tar.gz
2.安装jdk
解压到jkd软件包
[root@docker tomcat]# ls
apache-tomcat-10.1.7.tar.gz jdk-11.0.18 jdk-11.0.18_linux-x64_bin.tar.gz
复制二进制文件
[root@docker tomcat]# cp -r /data/tomcat/jdk-11.0.18 /usr/local/jdk/
配置环境变量,在/etc/profile追加以下两行,再激活变量source /etc/profile
export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:$JAVA_HOME/bin
3.检查jdk版本
检查jdk版本
[root@docker tomcat]# java -version
java version "11.0.18" 2023-01-17 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.18+9-LTS-195)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.18+9-LTS-195, mixed mode)
四、安装tomcat
1.下载tomcat
下载地址:https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.7/bin/
[root@docker tomcat]# ls
apache-tomcat-10.1.7.tar.gz jdk-11.0.18 jdk-11.0.18_linux-x64_bin.tar.gz
2.解压tomcat软件包
解压tomcat压缩包
[root@docker tomcat]# tar -xzf apache-tomcat-10.1.7.tar.gz -C /usr/local/
[root@docker tomcat]# mv /usr/local/apache-tomcat-10.1.7/ /usr/local/tomcat
3.设置环境变量
在/etc/profile追加以下两行,再激活变量source /etc/profile
export TOM_HOME=/usr/local/tomcat
export PATH=$PATH:$TOM_HOME/bin
4.查看tomcat版本
查看tomcat版本
[root@docker tomcat]# version.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Server version: Apache Tomcat/10.1.7
Server built: Feb 27 2023 20:25:27 UTC
Server number: 10.1.7.0
OS Name: Linux
OS Version: 3.10.0-957.el7.x86_64
Architecture: amd64
JVM Version: 11.0.18+9-LTS-195
JVM Vendor: Oracle Corporation
五、启动tomcat
1.启动tomcat服务
启动tomcat服务
[root@docker tomcat]# startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
2.检查tomcat服务状态
检查tomcat服务是否正常启动
[root@docker tomcat]# ps aux |grep tomcat
root 12288 9.8 1.7 5771868 135200 pts/0 Sl 10:57 0:04 /usr/local/jdk/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 12331 0.0 0.0 112812 948 pts/0 S+ 10:58 0:00 grep --color=auto tomcat
3.访问tomcat的web服务
访问地址:http://192.168.3.157:8080/
4.关闭tomcat服务
直接使用shutdown.sh 关闭tomcat服务
[root@docker tomcat]# ls /usr/local/tomcat/bin/
bootstrap.jar ciphers.sh daemon.sh migrate.bat shutdown.sh tool-wrapper.bat
catalina.bat commons-daemon.jar digest.bat migrate.sh startup.bat tool-wrapper.sh
catalina.sh commons-daemon-native.tar.gz digest.sh setclasspath.bat startup.sh version.bat
catalina-tasks.xml configtest.bat makebase.bat setclasspath.sh tomcat-juli.jar version.sh
ciphers.bat configtest.sh makebase.sh shutdown.bat tomcat-native.tar.gz
[root@docker tomcat]# shutdown.sh