yum install java-1.8.0-openjdk-devel
查JAVA版本
java -version
cd /tmp
wget http://apache.stu.edu.tw/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.tar.gz
tar zxvf apache-tomcat-8.5.42.tar.gz
mv apache-tomcat-8.5.42 /usr/tomcat8
useradd -M -d /usr/tomcat8 tomcat8
chown -R tomcat8. /usr/tomcat8
建立tomcat啟動檔在init
vi /etc/rc.d/init.d/tomcat8
====================================================================================
#!/bin/bash
# Tomcat8: Start/Stop Tomcat 8
#
# chkconfig: - 90 10
# description: Tomcat is a Java application Server.
. /etc/init.d/functions
. /etc/sysconfig/network
CATALINA_HOME=/usr/tomcat8
TOMCAT_USER=tomcat8
LOCKFILE=/var/lock/subsys/tomcat8
RETVAL=0
start(){
echo "Starting Tomcat8: "
su - $TOMCAT_USER -c "$CATALINA_HOME/bin/startup.sh"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
stop(){
echo "Shutting down Tomcat8: "
$CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $?
====================================================================================
chkconfig --add tomcat8
chkconfig tomcat8 on
去打開遊覽器打 ip:8080
查tomcat是否關閉
ps -ef|grep java