目录
一、Tomcat多实例
1.1 安装好 jdk
在部署 Tomcat 之前必须安装好 jdk,因为 jdk 是 Tomcat 运行的必要环境。
1. #关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
2. #将安装 Tomcat 所需软件包传到/opt目录下
apache-tomcat-9.0.16.tar.gz
jdk-8u201-linux-x64.rpm
3. #切换至/opt下,安装JDK
cd /opt
rpm -ivh jdk-8u201-linux-x64.rpm
4. #查看java版本
java -version
关闭防火墙
将安装 Tomcat 所需软件包传到/opt目录下
切换至/opt下,安装JDK
查看java版本
1.2 安装 tomcat
1. #切换至/opt下,解压tomcat包
cd /opt
tar -zxf apache-tomcat-9.0.16.tar.gz
2. #新建文件夹/usr/local/tomcat
mkdir /usr/local/tomcat
3. #将解压后的包拷贝至/usr/local/下并重命名
cp -a apache-tomcat-9.0.16 /usr/local/tomcat/tomcat1
cp -a apache-tomcat-9.0.16 /usr/local/tomcat/tomcat2
切换至/opt下,解压tomcat包
新建文件夹/usr/local/tomcat
将解压后的包拷贝至/usr/local/下并重命名
1.3 配置 tomcat 环境变量
vim /etc profile
export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$PATH
1.4修改tomcat2中的主配置文件
vim /usr/local/tomcat/tomcat2/conf/server.xml
22 <Server port="8006" shutdown="SHUTDOWN">
69 <Connector port="8081" protocol="HTTP/1.1"
116 <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
1.5修改启动脚本和关闭脚本
1. #修改tomcat1的/usr/local/tomcat/tomcat1/bin/startup.sh
vim /usr/local/tomcat/tomcat1/bin/startup.sh
export CATALINA_HOME1=/usr/local/tomcat/tomcat1
export CATALINA_BASE1=/usr/local/tomcat/tomcat1
export TOMCAT_HOME1=/usr/local/tomcat/tomcat1
2. #修改tomcat1 的/usr/local/tomcat/tomcat1/bin/shutdown.sh
vim /usr/local/tomcat/tomcat1/bin/shutdown.sh
export CATALINA_HOME1=/usr/local/tomcat/tomcat1
export CATALINA_BASE1=/usr/local/tomcat/tomcat1
export TOMCAT_HOME1=/usr/local/tomcat/tomcat1
3. #修改tomcat2的/usr/local/tomcat/tomcat2bin/startup.sh
vim /usr/local/tomcat/tomcat2/bin/startup.sh
export CATALINA_HOME1=/usr/local/tomcat/tomcat2
export CATALINA_BASE1=/usr/local/tomcat/tomcat2
export TOMCAT_HOME1=/usr/local/tomcat/tomcat2
4. #修改tomcat2的/usr/local/tomcat/tomcat2/bin/shutdown.sh
vim /usr/local/tomcat/tomcat2/bin/shutdown.sh
export CATALINA_HOME1=/usr/local/tomcat/tomcat2
export CATALINA_BASE1=/usr/local/tomcat/tomcat2
export TOMCAT_HOME1=/usr/local/tomcat/tomcat2
修改tomcat1的/usr/local/tomcat/tomcat1/bin/startup.sh
修改tomcat1 的/usr/local/tomcat/tomcat1/bin/shutdown.sh
修改tomcat2的/usr/local/tomcat/tomcat2bin/startup.sh
修改tomcat2的/usr/local/tomcat/tomcat2/bin/shutdown.sh :