Experimental Purpose:
1. Deploy multiple tomcat on the same server, allowing multiple projects on the server to run independently with different ports.
2, someone will ask me to get a tomcat to deploy multiple projects No, but you have to think that if you have this tomcat jumping, it is not all the items on this server are hung up. So just get the score.
Lab Environment:
1. CentOS 6.7
2, tomcat-8.0.45
3. JDK 1.8.0_144
Configure Tomcat, JDK, and so on. How to configure to see the previous chapters on how Tomcat is configured, I won't say much here.
After we've configured the first tomcat, we'll copy a few.
[Email protected] local]# cp-r apache-tomcat-8.0.45/test01
[Email protected] local]# cp-r apache-tomcat-8.0.45/test02
[Email protected] local]# cp-r apache-tomcat-8.0.45/test03
Edit/etc/profile
[[email protected] local] #vim/etc/profile
Export JAVA_HOME=/USR/LOCAL/JDK
Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH
Export classpath=. $CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib: $JAVA _home/lib/tools.jar
Export tomcat_home=/usr/local/test01
#
Export JAVA_HOME=/USR/LOCAL/JDK
Export path= $JAVA _home1/bin: $JAVA _home1/jre/bin: $PATH
Export classpath1=. $CLASSPATH 1: $JAVA _home1/lib: $JAVA _home1/jre/lib: $JAVA _home1/lib/tools.jar
Export tomcat_home1=/usr/local/test02
#
Export JAVA_HOME=/USR/LOCAL/JDK
Export path= $JAVA _home2/bin: $JAVA _home2/jre/bin: $PATH
Export classpath2=. $CLASSPATH 2: $JAVA _home2/lib: $JAVA _home2/jre/lib: $JAVA _home2/lib/tools.jar
Export tomcat_home2=/usr/local/test03
Configuring environment Variables for Catalina
[Email protected] local]# vim/etc/profile.d/catalina.sh
Export catalina_home=/usr/local/test01
Export path= $CATALINA _home/:bin: $PATH
[Email protected] local]# vim/etc/profile.d/catalina1.sh
Export catalina_home1=/usr/local/test02
Export path= $CATALINA _home1/:bin: $PATH
[Email protected] local]# vim/etc/profile.d/catalina2.sh
Export catalina_home2=/usr/local/test02
Export path= $CATALINA _home2/:bin: $PATH
Modify the Server.xml inside the three ports test01 do not have to change the default on the line, 02, 03 need to change, here I change 02. Methods are the same. Here are the three port numbers used by Tomcat
test01
8005
8080
8009
test02
8006
8081
8010
test03
8007
8082
8011
[Email protected] test02]# vim Conf/server.xml
<server port= "8006" shutdown= "Shutdown" >--default is 8005
<connector port= "8081" protocol= "http/1.1"--default is 8080
connectiontimeout= "20000"
redirectport= "8443"/>
<connector port= "8010" protocol= "ajp/1.3" redirectport= "8443"/>--default is 8009
Change the catalina_home below test02 bin/catalina.sh to the previous configuration in/etc/profile
[Email protected] test02]# vim bin/catalina.sh
: 1, $s/$CATALINA _home/$CATALINA _home1/g
# #vim Replace the command to change the $catalina_home to $catalina_home1 test03 is the same way to modify
In order to demonstrate that the effect was color-coded test01 with Tomcat A and so on
[Email protected] webapps]# vim root/index.jsp
<%@ page language= "java"%>
<title>tomcatA</title>
<body>
<table align= "centre" border= "1" >
<tr>
<td>session id</td>
<% Session.setattribute ("dklwj.com", "dklwj.com"); %>
<td> <%= Session.getid ()%></td>
</tr>
<tr>
<td>created on </td>
<td><%= session.getcreationtime ()%></td>
</tr>
</table>
</body>
Start three Tomcat and use SS-TNL to see if each Tomcat's port number is in the listening state.
[Email protected] zhz01]# SS-TNL
State recv-q send-q Local address:port Peer Addr Ess:port
LISTEN 0 1:: ffff:127.0.0.1:8005 :::*
LISTEN 0 1:: ffff:127.0.0.1:8006 :::*
LISTEN 0 1:: ffff:127.0.0.1:8007 :::*
LISTEN 0 100::: 8009 :::*
LISTEN 0 100::: 8010 :::*
LISTEN 0 100::: 8011 :::*
LISTEN 0 100::: 8080 :::*
LISTEN 0 100::: 8081 :::*
LISTEN 0 100::: 8082 :::*
LISTEN 0 128::: 22 :::*
In Client Authentication
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/A5/10/wKioL1m3TZORCgjhAABH_sxWldk155.jpg-wh_500x0-wm_ 3-wmp_4-s_2702117224.jpg "style=" Float:none; "title=" 8080.jpg "alt=" wkiol1m3tzorcgjhaabh_sxwldk155.jpg-wh_50 "/ >
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/06/5F/wKiom1m3TbrTPJjpAABIShAow9A120.jpg-wh_500x0-wm_ 3-wmp_4-s_2758776942.jpg "style=" Float:none; "title=" 8081.jpg "alt=" wkiom1m3tbrtpjjpaabishaow9a120.jpg-wh_50 "/ >
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/A5/10/wKioL1m3TZOAOBsvAABGrG1TK90035.jpg-wh_500x0-wm_ 3-wmp_4-s_40815280.jpg "style=" Float:none; "title=" 8083.jpg "alt=" Wkiol1m3tzoaobsvaabgrg1tk90035.jpg-wh_50 "/>
Enter a different port on the browser to access different items, if one of the hanging does not affect the other two, the rest of the normal work, as long as the problem of the fault of the station to find to repair it, the overall impact of the project is small. What are the questions I hope you will point out to learn from each other!
A single Linux server runs multiple separate tomcat services