在/etc/init.d/目录下生产tomcat文件, vim tomcat, 将下面的复制进去
#!/bin/bash
#
#
# /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="/soft/apache-tomcat-8.0.30"
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
赋予权限
chmod 755 tomcat.
在tomcat/bin/catalina.sh文件中加入以下语句:
export JAVA_HOME=/usr/java/jdk1.8.0
export CATALINA_HOME=/soft/apache-tomcat-8.0.30
export CATALINA_BASE=/soft/apache-tomcat-8.0.30
export CATALINA_TMPDIR=/soft/apache-tomcat-8.0.30/temp
启动tomcat
service tomcat start
停止tomcat
service tomcat stop
添加到服务列表
chkconfig --add tomcat
重启
reboot