CentOS 6.9安装Tomcat8.5.24与控制命令(启动、停止、重启)的设置

参考:

http://blog.csdn.net/jiaotuwoaini/article/details/54589261

-------------------------------------------------------------

1.安装JAVA SDK

yum list java*

yum install java-1.8.0-openjdk.x86_64


2.安装TOMCAT 8.5.24

wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz

tar -zxvf apache-tomcat-8.5.24.tar.gz

mv apache-tomcat-8.5.24 tomcat8

cd tomcat8/bin/

./startup.sh


防火墙开放8080端口

iptables -A INPUT -p tcp --dport 8080 -j ACCEPT

service iptables save

service iptables restart

3.开机时设置自动启动Tomcat

1). cd /etc/init.d

2). vi tomcat8

3).粘贴自启动命令。(本命令的文件名是:tomcat8)。

注意: 替换自己的JAVA环境变量和 TOMCAT的HOME

-----------------------------------------------------------------------------------
#!/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/lib/jvm/jre-1.8.0
export JAVA_HOME
CATALANA_HOME=/opt/tomcat8/
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
----------------------------------------------------------------------------------

4). 赋权限: chmod 755 tomcat8

5). 启动检查: service tomcat8 start

6). 设置开机自动启动:chkconfig tomcat8 on


注:

 chkconfig --list 查看开机自动启动软件的列表

你可能感兴趣的:(移动开发,Architecture)