當前位置:才華齋>計算機>作業系統>

linux系統設定tomcat自啟動

作業系統 閱讀(2W)

linux系統設定tomcat自啟動

linux系統設定tomcat自啟動

需要將tomcat加入自啟動佇列中,則需要進行如下的操作:

以root使用者登入系統:

cd /etc/rc.d/init.d/

vi tomcat

檔案內容參考如下:

#!/bin/sh

#

# tomcat: Start/Stop/Restart tomcat

#

# chkconfig: 2345 80 20

# description: Tomcat is a Java Servlet Container

#

#

# match these values to your environment:

export CATALINA_BASE=/usr/local/tomcat

export CATALINA_HOME=/usr/local/tomcat

export CATALINA_TMPDIR=/usr/local/tomcat/temp

export JRE_HOME=/usr/java/jdk15

# Source function library.

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

TOMCAT=/usr/local/tomcat

start() {

echo -n ___FCKpd___0"Starting Tomcat: "

$TOMCAT/bin/ start

}

stop() {

echo -n ___FCKpd___0"Stopping Tomcat: "

$TOMCAT/bin/ stop

}

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

status)

;;

status)

;;

restart)

stop

start

;;

*)

echo ___FCKpd___0"Usage: $0 {startstoprestart}"

;;

esac

exit $RETVAL

把 tomcat 修改為可執行的.檔案,命令參考如下:

chmod a+x tomcat

使用chkconfig命令把 tomcat 命令加入到系統啟動佇列中:

chkconfig --add tomcat

檢視apachectl的狀態:

chkconfig --list tomcat