Linux操作系统下Tomcat自启动的设置技巧

 安装了Tomcat 5.5,很简单,将下载下来的安装文件包解压,放入相应的目录中,然后在Linux环境中设置相应的如:JAVA_HOME、CATALINA_HOME等环境变量后,在Tomcat的bin目录下执行./catalina.sh run就能在终端方式上启动tomcat的服务勒。如果需要将tomcat加入自启动队列中,则需要进行如下的操作:

以root用户登录系统:

cd /etc/rc.d/init.d/
vi tomcat

文件内容参考如下:

#!/bin/sh
#
# tomcat: Start/Stop/Restart tomcat
#
# chkconfig: 2345 80 20
# description: Tomcat is a Java Servlet Container
#
#
# match these values to your environment:
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export CATALINA_TMPDIR=/usr/local/tomcat/temp
export JRE_HOME=/usr/java/jdk15

# Source function library.
. /etc/rc.d/init.d/functions

TOMCAT=/usr/local/tomcat

start() {
echo -n $"Starting Tomcat: "
$TOMCAT/bin/catalina.sh start
}

stop() {
echo -n $"Stopping Tomcat: "
$TOMCAT/bin/catalina.sh stop

}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
;;
status)
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
;;
esac
exit $RETVAL

把 tomcat 修改为可运行的文件,命令参考如下:

chmod a+x tomcat

使用chkconfig命令把 tomcat 命令加入到系统启动队列中:

chkconfig --add tomcat

查看apachectl的状态:

chkconfig --list tomcat

好了,全部完成,很简单的纪录,希望能帮助你,也让我自己记住!

你可能感兴趣的:(java,tomcat,linux,function,servlet,终端)