linux中tomcat怎么配置开机自动启动
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux中tomcat怎么配置开机自动启动相关的知识,希望对你有一定的参考价值。
参考技术A 方法一:linux 下tomcat开机自启动
修改Tomcat/bin/startup.sh 为:
export JAVA_HOME=/usr/java/j2sdk1.4.2_08
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/usr/local/tomcat/usr/local/tomcat/bin/catalina.sh start
在/etc/rc.d/rc.local中加入:
/usr/local/tomcat/bin/startup.sh
方法二:
1、把下面的代码保存为tomcat文件,并让它成为可执行文件 chmod 755 tomcat.
#!/bin/bash
#
# kenny kenny.zhou@tom.com
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat
# description: tomcat is a j2se server
# 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/tomcat"
case "$1"
instart)
if [ -f $CATALINA_HOME/bin/startup.sh ];then
echo $"Starting Tomcat"$CATALINA_HOME/bin/startup.shfi;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];then
echo $"Stopping Tomcat"$CATALINA_HOME/bin/shutdown.shfi;;
*)echo $"Usage: $0 start|stop"exit 1;;
esac
exit $RETVAL
2、将tomcat文件拷贝到/etc/init.d/下, 《Linux就该这么学》一起学习linux ,并运行:
chkconfig --add tomcat
3、在tomcat/bin/catalina.sh文件中加入以下语句:
export JAVA_HOME=/YOURPATH/tomcat/jdk
export CATALINA_HOME=/YOURPATH/tomcat
export CATALINA_BASE=/YOURPATH/tomcat
export CATALINA_TMPDIR=/YOURPATH/tomcat/temp
启动tomcat:
service tomcat start
停止tomcat:
service tomcat stop
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怎么配置开机自动启动的主要内容,如果未能解决你的问题,请参考以下文章