阿里云服务器搭建多个Tomcat
前言
在java web编程过程中,开发和部署少不了使用Tomcat,一般情况下只用一个Tomcat就够,特定情况需要配置多个Tomcat,那么现在和我一起踩一踩这个坑吧!😁【这里配置的是不同版本的三个Tomcat(8、9、10),同版本的也可以一样操作,🤫熟悉之后可以配置再几个哦】
1.环境准备
- OS:CentOS 8.2 64位
- JDK:1.8.0_281
- Tomcat:8.5.70、9.0.52、10.0.10
1.1 下载Tomcat
tomcat 8.5.70
tomcat 9.0.52
tomcat 10.0.10
使用wget下载或浏览器下载后上传到服务器
#8.5.70
wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.70/bin/apache-tomcat-8.5.70.tar.gz
#9.0.52
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.52/bin/apache-tomcat-9.0.52.tar.gz
#10.0.10
wget https://downloads.apache.org/tomcat/tomcat-10/v10.0.10/bin/apache-tomcat-10.0.10.tar.gz
1.2 解压文件
#8.5.70
tar -zxvf apache-tomcat-8.5.70.tar.gz
#9.0.52
tar -zxvf apache-tomcat-9.0.52.tar.gz
#10.0.10
tar -zxvf apache-tomcat-10.0.10.tar.gz
1.3 重命名
#8.5.70
mv apache-tomcat-8.5.70 tomcat9
#9.0.52
mv apache-tomcat-9.0.52 tomcat9
#10.0.10
mv apache-tomcat-10.0.10 tomcat10
1.4 查看server.xml文件
打开任意一个即可,这里打开的是tomcat 8的server.xml文件
cat tomcat8/conf/server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!--由于篇幅比较长,此处省略若干行-->
<