Linux Centos6.10下,配置tomcat随系统启动

修改配置文件 配置java_home

vi /usr/local/tomcat/apache-tomcat-6.0.48/bin/setclasspath.sh

在红框的位置增加

export JAVA_HOME=/usr/java/jdk1.7.0_79

Linux Centos6.10下,配置tomcat随系统启动_第1张图片

执行创建文件)

vi /etc/rc.d/init.d/tomcat

 

复制一下内容到文件里

 

#!/bin/bash

#

# /etc/rc.d/init.d/tomcat

# init script for tomcat precesses

#

# processname: tomcat

# description: tomcat is a j2se server

# chkconfig: 2345 86 16

# description: Start up the Tomcat servlet engine.

 

if [ -f /etc/init.d/functions ]; then

. /etc/init.d/functions

elif [ -f /etc/rc.d/init.d/functions ]; then

. /etc/rc.d/init.d/functions

else

echo -e "/atomcat: unable to locate functions lib. Cannot continue."

exit -1

fi

 

RETVAL=$?

CATALINA_HOME="/usr/local/tomcat/apache-tomcat-6.0.48/"

 

case "$1" in

start)

if [ -f $CATALINA_HOME/bin/startup.sh ];

then

echo $"Starting Tomcat"

$CATALINA_HOME/bin/startup.sh

fi

;;

stop)

if [ -f $CATALINA_HOME/bin/shutdown.sh ];

then

echo $"Stopping Tomcat"

$CATALINA_HOME/bin/shutdown.sh

fi

;;

*)

echo $"Usage: $0 {start|stop}"

exit 1

;;

esac

 

exit $RETVAL

 

执行

chmod 775 /etc/rc.d/init.d/tomcat

将tomcat变成可执行文件

 

注册为服务,并且自启动

执行

chkconfig tomcat on

 

重启系统进行测试

执行

reboot

你可能感兴趣的:(tomcat)