首页 > 代码库 > linux下配置tomcat开机自启动

linux下配置tomcat开机自启动

Linux下配置tomcat开机自启动


 
1、写一个tomcat脚本,内容如下,设置其权限为755,放在/etc/init.d/目录下
#!/bin/bash
#
# /etc/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.

if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo -e "/atomcat: unable to locate functions lib. Cannot continue."
exit -1
fi

RETVAL=$?
CATALINA_HOME="/usr/local/tomcat85"

case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ]; then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac

exit $RETVAL

 

2、在catalina.sh中(具体位置为export QIBM_MULTI_THREADED=Y之下)加入以下三行:

export JAVA_HOME=/usr/local/jdk18
export CATALINA_BASE=/usr/local/tomcat85
export CATALINA_HOME=/usr/local/tomcat85
export CATALINA_TMPDIR=/usr/local/tomcat85/temp

 

3、将启动脚本加入到chkconfig的管理之下

chkconfig --add tomcat

 

4、可以用services tomcat start|stop来管理tomcat

 

 


 

linux下配置tomcat开机自启动