1. cd /etc/init.d

  2. vi tomcat8

  3. 粘贴自启动命令 注意替换自己的Java环境变量和 TOMCAT的HOME

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash        
#
# tomcat startup script for the Tomcat server
#
# chkconfig: 345 80 20
# description: start the tomcat deamon
#
# Source function library
. /etc/rc.d/init.d/functions

prog=tomcat8
JAVA_HOME=/opt/jdk1.8.0_40
export JAVA_HOME
CATALANA_HOME=/opt/apache-tomcat-8.0.20/
export CATALINA_HOME

case "$1" in
start)
echo "Starting Tomcat..."
$CATALANA_HOME/bin/startup.sh
;;

stop)
echo "Stopping Tomcat..."
$CATALANA_HOME/bin/shutdown.sh
;;

restart)
echo "Stopping Tomcat..."
$CATALANA_HOME/bin/shutdown.sh
sleep 2
echo
echo "Starting Tomcat..."
$CATALANA_HOME/bin/startup.sh
;;

*)
echo "Usage: $prog {start|stop|restart}"
;;
esac
exit 0

4.保存退出
5.chmod 755 tomcat8 赋权限
6.service tomcat8 start 启动检查
7.chkconfig tomcat8 on