1/进入tomcat官网下载适合的版本

2/使用wget下载tomcat到项目目录下,
a.wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.tar.gz
3/解压tomcat
a.tar -zxvf apache-tomcat-9.0.14.tar.gz
4/进入apache-tomcat-9.0.14./bin 目录下启动 ./startup.sh
5/测试是否启动成功
6/配置多个tomcat
a.打开/etc/profile
b.添加下面代码
#first tomcat
CATALINA_BASE=/home/wwwroot/p1/apache-tomcat-9.0.14
CATALINA_HOME=/home/wwwroot/p1/apache-tomcat-9.0.14
TOMCAT_HOME=/home/wwwroot/p1/apache-tomcat-9.0.14
export CATALINA_BASE CATALINA_HOME TOMCAT_HOME
#second tomcat
CATALINA_2_BASE=/home/wwwroot/p3/apache-tomcat-9.0.14
CATALINA_2_HOME=/home/wwwroot/p3/apache-tomcat-9.0.14
TOMCAT_2_HOME=/home/wwwroot/p3/apache-tomcat-9.0.14
export CATALINA_2_BASE CATALINA_2_HOME TOMCAT_2_HOME
c.更新profile
source /etc/profile
d.进入第二个tomcat下修bin/下的catalina.sh
在# OS specific support. $var _must_ be set to either true or false.下添加如下代码
export CATALINA_BASE=$CATALINA_2_BASE
export CATALINA_HOME=$CATALINA_2_HOME

e.修改conf下的server.xml中三个端口
f.无法启动分析
启动tomcat无法访问
-------三个端口号不能与上一个tomcat重复 端口号规则: 8005 ->500 8080->80 8009->800
查看tomcat是否运行
ps -ef |grep tomcat
查看三个端口号是否启动
netstat -tunlp|grep 8080
netstat -tunlp|grep 8005
netstat -tunlp|grep 8009
如果没有正常启动,编辑$JAVA_HOME/jre/lib/security/java.security中的配置
将:securerandom.source=file:/dev/random
改为: securerandom.source=file:/dev/urandom
网友评论