(1)在/etc/init.d的目录中新建tomcat脚本,内容如下
#!/bin/bash
# Tomcat auto-start
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
# JAVA_HOME是jdk主目录
export JAVA_HOME=/etc/jdk1.7/jdk1.7.0_76
case $1 in
start)
sh /etc/tomcat/apache-tomcat-7.0.69/bin/startup.sh
;;
stop)
sh /etc/tomcat/apache-tomcat-7.0.69/bin/shutdown.sh
;;
restart)
sh /etc/tomcat/apache-tomcat-7.0.69/bin/shutdown.sh
sh /etc/tomcat/apache-tomcat-7.0.69/bin/startup.sh
;;
esac
exit 0
(4)service tomcat start 搞定
(2)执行sudo chmod 755 /etc/init.d/tomcat 是tomcat文件为可执行的
(3)将tomcat添加到系统服务中:sysv-rc-conf tomcat on