****************************************
Tomcat-7to Linux Service
****************************************
--------------------DocumentedInformation
Creater:YCW
CreateDate:2011-08-10
Contactemail:tonyyin2008@foxmail.com
--------------------SoftwareEnvironment
·VMware Workstation 7.1.4 build-385536
·Red Hat EnterpriseLinux (RHEL) 4
·Apche-Tomcat-7.0.6
--------------------OperationSteps
[1]Download Tomcat-7
URL:http://tomcat.apache.org/download-70.cgi
Tips:此处仅介绍关于Tomcat7配置Linux Service的部分,Tomcat的基础配置请参阅《Tomcat安装与配置》
[2]Configure Tomcat-7
[root@localhost ~]cd /tomcat7
[root@localhost tomcat7]cd /bin
[root@localhost bin]cp catalina.sh/etc/init.d
[root@localhost tomcat7]cd /etc/init.d
[root@localhost init.d]pwd
/etc/init.d
[root@localhost init.d]mv catalina.shtomcat
[root@localhost init.d]vi tomcat
--------------------
在#!/bin/bash下输入
# chkconfig: 2345 10 90
# description:Tomcat service
在#OSspecific support................上输入
CATALINA_HOME=/tomcat7
JAVA_HOME=/usr/java/jdk1.6.0_10
保存并退出文件
--------------------
[root@localhost init.d]chmod +x tomcat
[root@localhost init.d]cd /
[root@localhost /]vi /etc/profile
--------------------
在最后一行输入
#CATALINA_HOME
CATALINA_HOME=/tomcat7
export CATALINA_HOME
保存并退出文件
--------------------
[root@localhost /]source /etc/profile
[3]Add tomcat to service list
[root@localhost /]chkconfig --add tomcat
[4]Check service list
[root@localhost /]chkconfig --list tomcat
tomcat 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[5]Test tomcat service
[root@localhost /]service tomcat
--------------------
Using CATALINA_BASE: /tomcat7
UsingCATALINA_HOME: /tomcat7
UsingCATALINA_TMPDIR: /tomcat7/temp
Using JRE_HOME: /usr/java/jdk1.6.0_10
UsingCLASSPATH: /tomcat7/bin/bootstrap.jar:/tomcat7/bin/tomcat-juli.jar
Usage: catalina.sh ( commands ... )
.
.
.
.
.
--------------------
[6]Start tomcat service
[root@localhost /]service tomcat start
[7]OK!