1.添加环境变量:vi /etc/profile
CATALINA_BASE=/opt/tomcat/tomcat-9.0.46
CATALINA_HOME=/opt/tomcat/tomcat-9.0.46
TOMCAT_HOME=/opt/tomcat/tomcat-9.0.46
export CATALINA_BASE CATALINA_HOME TOMCAT_HOME
CATALINA1_BASE=/opt/tomcat/tomcat1-9.0.46
CATALINA1_HOME=/opt/tomcat/tomcat1-9.0.46
TOMCAT1_HOME=/opt/tomcat/tomcat1-9.0.46
export CATALINA1_BASE CATALINA1_HOME TOMCAT1_HOME
CATALINA2_BASE=/opt/tomcat/tomcat2-9.0.46
CATALINA2_HOME=/opt/tomcat/tomcat2-9.0.46
TOMCAT2_HOME=/opt/tomcat/tomcat2-9.0.46
export CATALINA2_BASE CATALINA2_HOME TOMCAT2_HOME
CATALINA3_BASE=/opt/tomcat/tomcat3-9.0.46
CATALINA3_HOME=/opt/tomcat/tomcat3-9.0.46
TOMCAT3_HOME=/opt/tomcat/tomcat3-9.0.46
export CATALINA3_BASE CATALINA3_HOME TOMCAT3_HOME
2.修改每个tomcat根目录bin下的catalina.sh文件
找到# OS specific support. $var must be set to either true or false.
在此行下添加
# OS specific support. $var _must_ be set to either true or false.
export CATALINA_BASE=$CATALINA_BASE
export CATALINA_HOME=$CATALINA_HOME
# OS specific support. $var _must_ be set to either true or false.
export CATALINA_BASE=$CATALINA1_BASE
export CATALINA_HOME=$CATALINA1_HOME
# OS specific support. $var _must_ be set to either true or false.
export CATALINA_BASE=$CATALINA2_BASE
export CATALINA_HOME=$CATALINA2_HOME
# OS specific support. $var _must_ be set to either true or false.
export CATALINA_BASE=$CATALINA3_BASE
export CATALINA_HOME=$CATALINA3_HOME
3.修改每个tomcat 在 conf 下的 server.xml 中修改其的端口号:
#修改关闭端口:
<Server port="8006" shutdown="SHUTDOWN" >
#修改访问端口:
<Connector port="8088" URIEncoding="UTF-8" redirectPort="8443" connectionTimeout="20000" protocal="HTTP/1.1">
#修改监听端口:
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443">
参考:
https://www.cnblogs.com/linnuo/p/9922581.html
https://blog.csdn.net/u012851654/article/details/79410574
https://blog.csdn.net/github_38383183/article/details/78608229