1、在/usr/share/tomcat8/bin中有commons-daemon-native.tar.gz 压缩包
2、解压commons-daemon-native.tar.gz #tar -zxvf commons-daemon-native.tar.gz
3、解压完成,出现commons-daemon-1.0.15-native-src文件夹(目录)
4、执行configure 文件
cd commons-daemon-1.0.15-native-src/unix ./configure
5、编译 [root@localhost ~]# make
6、 编译完成后出现jsvc文件夹,复制jsvc到/usr/share/tomcat8/bin目录下面 [root@localhost ~]# cp jsvc ../../
7、在/etc/init.d/目录下编写tomcat8启动服务配置文件。 [root@localhost ~]#cd /etc/init.d/ [root@localhost ~]# vi tomcat8
#!/bin/bash
#startup script for tomcat on linux
# chkconfig: 2345 10 90
# description: tomcat sever ....
#filename tomcat.sh
#JAVA_HOME=/opt/zimbra/jdk-1.7.0_51
TOMCAT_HOME=/opt/apache-tomcat-8.0.20
################################################
start_tomcat=$TOMCAT_HOME/bin/daemon.sh
stop_tomcat=$TOMCAT_HOME/bin/daemon.sh
start() {
echo -n "Starting tomcat: "
${start_tomcat} start
echo "tomcat start ok"
}
stop() {
echo -n "Shutdown tomcat"
${stop_tomcat} stop
echo "tomcat stop ok"
}
#how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
8、录入完成,按Esc键。输入: wq保存退出并赋予/etc/init.d/tomcat8文件可执行权限 [root@localhost~]# chmod 777 /etc/init.d/tomcat8 ------------------添加服务-----------------------------------------
9、[root@localhost~] #chkconfig --add tomcat8 ##添加tomcat服务
10、[root@localhost~] #chkconfig –list |grep tomcat8 ##查看tomcat服务是否被添加 --------------------启动服务---------------------------------------------
11、[root@localhost~] # service tomcat8 start ##启动tomcat服务
12、[root@localhost~] # service tomcat8 stop ##停止tomcat服务
13、[root@localhost~] # service tomcat8 restart ##重启tomcat
14、[root@localhost~] # service tomcat8 status ##查看tomcat服务启动状态 然后给普通用户tomcat的权限,就可以了。
来源:oschina
链接:https://my.oschina.net/u/2346909/blog/491136