jsvc将tomcat配置成服务

一、在/usr/share/tomcat8/bin中有commons-daemon-native.tar.gz 压缩包linux

二、解压commons-daemon-native.tar.gz #tar -zxvf commons-daemon-native.tar.gzapache

三、解压完成,出现commons-daemon-1.0.15-native-src文件夹(目录)tomcat

四、执行configure 文件bash

cd commons-daemon-1.0.15-native-src/unix ./configureunix

五、编译 [root@localhost ~]# makerest

六、 编译完成后出现jsvc文件夹,复制jsvc到/usr/share/tomcat8/bin目录下面 [root@localhost ~]# cp jsvc ../../code

七、在/etc/init.d/目录下编写tomcat8启动服务配置文件。 [root@localhost ~]#cd /etc/init.d/ [root@localhost ~]# vi tomcat8ip

#!/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

八、录入完成,按Esc键。输入: wq保存退出并赋予/etc/init.d/tomcat8文件可执行权限 [root@localhost~]# chmod 777 /etc/init.d/tomcat8 ------------------添加服务-----------------------------------------it

九、[root@localhost~] #chkconfig --add tomcat8 ##添加tomcat服务io

十、[root@localhost~] #chkconfig –list |grep tomcat8 ##查看tomcat服务是否被添加 --------------------启动服务---------------------------------------------

十一、[root@localhost~] # service tomcat8 start ##启动tomcat服务

十二、[root@localhost~] # service tomcat8 stop ##中止tomcat服务

1三、[root@localhost~] # service tomcat8 restart ##重启tomcat

1四、[root@localhost~] # service tomcat8 status ##查看tomcat服务启动状态 而后给普通用户tomcat的权限,就能够了。

相关文章
相关标签/搜索