CentOS7,安装Tomcat8.5、JDK1.8,并设置开机启动(Linux CentOS Tomcat、JDK+Tomcat、Tomcat开机自启动)

时间:2020-11-29 15:24:44
1、下载JDK1.8、Tomcat8
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 
http://tomcat.apache.org/download-80.cgi
CentOS7,安装Tomcat8.5、JDK1.8,并设置开机启动(Linux CentOS Tomcat、JDK+Tomcat、Tomcat开机自启动)
 
CentOS7,安装Tomcat8.5、JDK1.8,并设置开机启动(Linux CentOS Tomcat、JDK+Tomcat、Tomcat开机自启动)
 

2、解压文件 tar -zxvf xxxxxxxxxxxxx.gz
jdk放到 /usr/local/javajdk tomcat放到 /usr/local/tomcat

3、设置jdk环境变量
  1. vi /etc/profile
  1. #在底部添加
  2. JAVA_HOME=/usr/local/javajdk
  3. PATH=$JAVA_HOME/bin:$PATH
  4. CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
  5. export PATH JAVA_HOME CLASSPATH
  1. source /etc/profile


4、启动tomcat
  1. /usr/local/tomcat/bin/startup.sh
  2. #/usr/local/tomcat/bin/shutdown.sh
可能要防火墙添加8080端口
  1. firewall-cmd --zone=public --add-port=8080/tcp --permanent
  2. sudo firewall-cmd --reload

5、设置开机自启动
如果要开机自启动tomcat,配置如下:
  1. chmod +x /etc/rc.d/rc.local
  2. vi /etc/rc.d/rc.local
在文件中添加下面几行:
  1. export JAVA_HOME=/usr/local/javajdk
  2. export PATH=$JAVA_HOME/bin:$PATH
  3. export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
  4. /usr/local/tomcat/bin/startup.sh


(完)