centOS 6.5 开机启动 tomcat

前端之家收集整理的这篇文章主要介绍了centOS 6.5 开机启动 tomcat前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1: 安装jdk tomcat后 能访问tomcat成功

2:注意要在防火墙开启你的tomcat开启的端口号(操作如下)

修改文件路径和内容如下

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

添加完毕 。 source/etc/sysconfig/iptables 使修改文件生效

3:在/etc/rc.local 目录下加入以下信息

(可以覆盖,要改你的toncat和jdk的安装路径

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
export JAVA_HOME=/opt/jdk1.8.0_101
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/opt/apache-tomcat-8.5.4

#tomcat自启动

/opt/apache-tomcat-8.5.4/bin/startup.sh

touch /var/lock/subsys/local

4:重启系统、tomcat已经开机启动成功

或者 直接在rc.local最下面增加两行代码、依旧可以开机重启

export JAVA_HOME=/opt/jdk1.8.0_101 ---JDK路径 /opt/software/apache-tomcat-8.5.4/bin/startup.sh start --- tomcat启动命令

猜你在找的CentOS相关文章