阿里云Linux ubantu配置tomcat开机启动

1、安装软件

JDK 安装路劲:/usr/lib/jvm/jdk8

Tomcat 安装路劲:/usr/local/share/tomcat8

2、转到 /etc/init.d目录下创建 tomcat文件。

cd /etc/init.d
vim tomcat

    文件内容如下:    

#!/bin/bash
# Tomcat auto-start
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
# JAVA_HOME是jdk主目录
export JAVA_HOME=/usr/lib/jvm/jdk8
case $1 in
start)
        sh /usr/local/share/tomcat8/bin/startup.sh
        ;;
stop)
        sh /usr/local/share/tomcat8/bin/shutdown.sh
        ;;
restart)
        sh /usr/local/share/tomcat8/bin/shutdown.sh
        sh /usr/local/share/tomcat8/bin/startup.sh
        ;;
esac
exit 0

3、赋予文件执行权限

sudo chmod 777 /etc/init.d/tomcat

4、添加(或删除)启动服务

添加:update-rc.d -f tomcat defaults
删除:update-rc.d -f tomcat remove

test!

over!

你可能感兴趣的:(阿里云Linux ubantu配置tomcat开机启动)