Linux下配置tomcat开机自启动

Linux下配置tomcat开机自启动

1.配置JAVA环境

$ vim /etc/profile

插入下方代码:
# java安装地址
export JAVA_HOME=/usr/local/apps/jdk1.8  
# bin目录地址
export JAVA_BIN=/usr/local/apps/jdk1.8/bin    
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH

Linux下配置tomcat开机自启动

 

 

2.验证启动tomcat

进入tomcat中的bin目录,并输入./startup.sh  屏幕输出如下说明tomcat已启动

Linux下配置tomcat开机自启动

 

 

3.配置tomcat开机自启动

1. cd  /etc/rc.d/init.d
2. vim tomcat
3. 粘贴下面代码保存
4. 设置权限 chmod 777 /etc/rc.d/init.d/tomcat
5. 设置开机自启动 sudo chkconfig rtlsmgr on
6. 验证:重启服务器访问
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcat
# Tomcat auto-start
# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network

export JAVA_HOME=/usr/local/apps/jdk1.8
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.
# tomcat安装地址
export CATALINA_HOME=/usr/local/apps/tomcat

case "$1" in
start)
      sleep 30  
      ${CATALINA_HOME}/bin/startup.sh
      exit 0
      ;;
stop)
      ${CATALINA_HOME}/bin/shutdown.sh
      exit 0
      ;;
debug)
      ${CATALINA_HOME}/bin/shutdown.sh
      ${CATALINA_HOME}/bin/catalina.sh run
      exit 0
      ;;
force-reload|restart)
      ${CATALINA_HOME}/bin/startup.sh
      ${CATALINA_HOME}/bin/shutdown.sh
      exit 0
      ;;
*)
      echo "Usage: /etc/rc.d/init.d/tomcat{start|stop|restart|force-reload|debug}"
      exit 1
      ;;
esac
exit 0
?

4.以服务方式启动

service tomcat start 启动
service tomcat restart 重启
service tomcat stop 停止

 

Linux下配置tomcat开机自启动

上一篇:R6900路由器相关shell操作指令


下一篇:Linux:-bash: unzip: command not found