LINUX架构

centos6.9下单机部署多个tomcat实战

2018-06-28  本文已影响61人  茶还是咖啡

1.新建安装目录

[root@xrw /]# mkdir /developer/setup/  -p

2.下载压缩包

去apache官网下载tomcat,新建一个目录用来存放下载的tomcat的压缩包,本文使用tomcat8.5

tomcat压缩包下载

鼠标右键复制链接地址。在centos中使用wget指令进行下载。

[root@xrw setup]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.32/bin/apache-tomcat-8.5.32.tar.gz
[root@xrw setup]# ls
apache-tomcat-8.5.31.tar.gz

3.解压,修改配置文件,配置环境变量,运行第一个tomcat

[root@xrw setup]# tar -zxvf apache-tomcat-8.5.31.tar.gz -C../
[root@xrw setup]# cd ..
[root@xrw developer]# ls
apache-tomcat-8.5.31  setup
[root@xrw developer]# mv apache-tomcat-8.5.31/ tomcat1
[root@xrw developer]# ls
setup  tomcat1
[root@xrw developer]# cd tomcat1/
[root@xrw tomcat1]# pwd
/developer/tomcat1

/developer/tomcat1复制该路径
打开配置环境变量的文件,并在最下面添加如下内容:

[root@xrw tomcat1]# vim /etc/profile
#tomcat
export CATALINA_HOME=/developer/tomcat1

保存并退出,重新载入该文件使得生效

[root@xrw tomcat1]# source /etc/profile
[root@xrw tomcat1]# cd /
[root@xrw /]# cd /developer/tomcat1/bin/
[root@xrw bin]# ./startup.sh 
Using CATALINA_BASE:   /developer/tomcat1
Using CATALINA_HOME:   /developer/tomcat1
Using CATALINA_TMPDIR: /developer/tomcat1/temp
Using JRE_HOME:        /usr/local/java/jdk1.8.0_171
Using CLASSPATH:       /developer/tomcat1/bin/bootstrap.jar:/developer/tomcat1/bin/tomcat-juli.jar
Tomcat started.

tomcat开启,尝试访问一下,浏览器输入http://ip:8080

tomcat开启成功

复制tomcat1,并重新配置环境变量

[root@xrw developer]# cp tomcat1 tomcat2 -a
[root@xrw developer]# ls
setup  tomcat1  tomcat2
#tomcat
export CATALINA_1_BASE=/developer/tomcat1
export CATALINA_1_HOME=/developer/tomcat1
export TOMCAT_1_HOME=/developer/tomcat1

export CATALINA_2_BASE=/developer/tomcat2
export CATALINA_2_HOME=/developer/tomcat2
export TOMCAT_2_HOME=/developer/tomcat2

重新载入环境变量

[root@xrw developer]# source /etc/profile

下面的操作只修改Tomcat2

export CATALINA_BASE=$CATALINA_2_BASE
export CATALINA_HOME=$CATALINA_2_HOME
catalina.sh

保存并退出。

<Server port="9005" shutdown="SHUTDOWN">

2.将8080改成9080

<Connector port="9080" protocol="HTTP/1.1" connectionTimeout="20000"  redirectPort="8443" />

3.将8009改成9009

<Connector port="9009" protocol="AJP/1.3" redirectPort="8443" />

测试

同时启动tomcat1和tomcat2

[root@xrw tomcat1]# ./bin/startup.sh 
Using CATALINA_BASE:   /developer/tomcat1
Using CATALINA_HOME:   /developer/tomcat1
Using CATALINA_TMPDIR: /developer/tomcat1/temp
Using JRE_HOME:        /usr/local/java/jdk1.8.0_171
Using CLASSPATH:       /developer/tomcat1/bin/bootstrap.jar:/developer/tomcat1/bin/tomcat-juli.jar
Tomcat started.

tomcat2

[root@xrw tomcat2]# ./bin/startup.sh 
Using CATALINA_BASE:   /developer/tomcat2
Using CATALINA_HOME:   /developer/tomcat2
Using CATALINA_TMPDIR: /developer/tomcat2/temp
Using JRE_HOME:        /usr/local/java/jdk1.8.0_171
Using CLASSPATH:       /developer/tomcat2/bin/bootstrap.jar:/developer/tomcat2/bin/tomcat-juli.jar
Tomcat started.

注意tomcat使用的环境变量是不同的。

tomcat2

部署完毕!

上一篇下一篇

猜你喜欢

热点阅读