Multiple tomcat servers run on a linux server. Because the tomcat process names are "java", you cannot add them all as services, creates multiple soft links for java.
The procedure is as follows:
1. Establish a soft connection to java
Ln-sf/opt/jre1.6.0 _ 30/bin/java/usr/bin/tomcat-bid
After tomcat is started, check that the process name is tomcat-bid. Use a different name for each tomcat.
2. Modify the setclasspath. sh file in the tomcat/bin directory.
Find the _ RUNJAVA = "$ JRE_HOME"/bin/java line, usually at the end.
To:
_ RUNJAVA = "$ JRE_HOME"/bin/tomcat-bid
Tomcat-bid is the process name, and each tomcat is changed to a different name.
3. Create the tomcat-bid file in the/etc/init. d/directory. Note that the permission should be set to executable. The content is as follows:
#! /Bin/bash
#
# Startup script for the tomcat
#
# Chkconfig: 345 80 15
# Description: Tomcat with bid
# Source function library.
./Etc/rc. d/init. d/functions
Start (){
If [-z $ (/sbin/pidof tomcat-bid)]; then
Echo "Starting tomcat-bid"
/Opt/tomcat-bid/bin/startup. sh
Touch/var/lock/subsys/tomcat-bid
Else
Echo "tomcat already running"
Fi
}
Stop (){
If [! -Z $ (/sbin/pidof tomcat-bid)]; then
Echo "Shutting down tomcat"
/Opt/tomcat-bid/bin/shutdown. sh
Until [-z $ (/sbin/pidof java)]; do:; done
Rm-f/var/lock/subsys/tomcat-bid
Else
Echo "tomcat not running"
Fi
}
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Restart)
Stop
Start
;;
Status)
/Opt/tomcat-bid/bin/catalina. sh version
;;
*)
Echo "Usage: $0 {start | stop | restart | status }"
Esac
Exit 0
4. Add the service to linux
Chkconfig -- add tomcat-bid
Chkconfig tomcat-bid on
View tomcat service status
Chkconfig -- list tomcat-bid
5. Use service commands to control tomcat
Service tomcat-bid status
Author surelei