tomcat
1.java容器、web容器、web中间件
下载依赖包jdk包和tomcat包
wget https://download.oracle.com/otn-pub/java/jdk/16.0.2%2B7/d4a915d82b4c4fbb9bde534da945d746/jdk-16.0.2_linux-x64_bin.tar.gz wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.52/bin/apache-tomcat-9.0.52.tar.gz
2.解压jdk包 tar -zxf jdk-16.0.2_linux-x64_bin.tar.gz -C /usr/local/ ln -n /usr/local/jdk-16.0.2 /usr/local/java 3.配置java环境变量 vim /etc/profile JAVA_HOME=/usr/local/java PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH 加载java环境变量 source /etc/profile 查看java环境变量是否生效 java -version 解压tomcat包 tar -zxf apache-tomcat-9.0.52.tar.gz -C /usr/local/tomcat ln -n /usr/local/apache-tomcat-9.0.52 /usr/local/tomcat 配置tomcat环境变量 CATALINA_HOME=/usr/local/tomcat export CATALINA_HOME
tomcat目录说明
vim server.xml
测试结果
多实例构建
创建三个目录
拷贝文件到三个目录
\cp -r /usr/local/tomcat/{conf,logs,temp,work} /usr/local/tomcat/instace1 \cp -r /usr/local/tomcat/{conf,logs,temp,work} /usr/local/tomcat/instace2 \cp -r /usr/local/tomcat/{conf,logs,temp,work} /usr/local/tomcat/instace3
需要修改conf中server.xml中端口,避免端口冲突,指定web应用位置目录
创建启动脚本
###多实例启动脚本 vim inid.sh #!/bin/bash #instance1 ./etc/init.d/functions export CATALINA_BASE="/usr/local/tomcat/instace1" #修改为对应的目录 case "$1" in start) $CATALINA_HOME/bin/startup.sh ;; stop) $CATALINA_HOME/bin/shutdown.sh ;; restart) $CATALINA_HOME/bin/shutdown.sh sleep 5 $CATALINA_HOME/bin/startup.sh ;; esac export JAVA_OPTS=‘-Xms64m -Xmx128m‘
把脚本cp对应的目录赋执行权执行 ./inid.sh start 启动tomcat实例
验证结果