centos7 設定tomcat自啟動

快樂就好發表於2018-10-17

1 .vi  /etc/init.d/tomcat8

#!/bin/bash 
# 
# tomcat startup script for the Tomcat server 
# 
# chkconfig: 345 80 20 
# description: start the tomcat deamon 
# 
# Source function library 
. /etc/rc.d/init.d/functions 

prog=tomcat8 
JAVA_HOME=/usr/java/jdk1.8.0_121
export JAVA_HOME 
CATALANA_HOME=/home/tomcat/apache-tomcat-8.5.34
export CATALINA_HOME 

case "$1" in 
start) 
echo "Starting Tomcat..." 
$CATALANA_HOME/bin/startup.sh 
;; 

stop) 
echo "Stopping Tomcat..." 
$CATALANA_HOME/bin/shutdown.sh 
;; 

restart) 
echo "Stopping Tomcat..." 
$CATALANA_HOME/bin/shutdown.sh 
sleep 2 
echo 
echo "Starting Tomcat..." 
$CATALANA_HOME/bin/startup.sh 
;; 

*) 
echo "Usage: $prog {start|stop|restart}" 
;; 
esac 
exit 0

2.chmod 755 tomcat8 賦許可權

3.service tomcat8 start 啟動檢查

4. chkconfig tomcat8 on

 

輔助:查詢jdk目錄

which java

ls -lrt /usr/bin/java

ls -lrt /etc/alternatives/java

相關文章