1、[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# iptables -F
[root@localhost ~]# setenforce 0
2、查看jdk是否安装
[root@localhost ~]# java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (rhel-2.5.4.2.el7_0-x86_64 u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
3、如果安装了,卸载rpm安装的jdk
[root@localhost ~]# rpm -qa | grep -i openjdk
java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x86_64
java-1.7.0-openjdk-headless-1.7.0.75-2.5.4.2.el7_0.x86_64
卸载:
(1)[root@localhost ~]# rpm -e java-1.7.0-openjdk
错误:依赖检测失败:
java >= 1:1.6 被 (已安裝) libreoffice-core-1:4.2.6.3-5.el7.x86_64 需要
java >= 1.5 被 (已安裝) jline-1.0-8.el7.noarch 需要
java-1.7.0-openjdk 被 (已安裝) icedtea-web-1.5.2-0.el7.x86_64 需要
jre >= 1.5.0 被 (已安裝) libreoffice-ure-1:4.2.6.3-5.el7.x86_64 需要
如果报错了是因为有依赖关系,后面加上--nodeps
[root@localhost ~]# rpm -e java-1.7.0-openjdk --nodeps
[root@localhost ~]# rpm -e java-1.7.0-openjdk-headless --nodeps
(2)把java的绝对路径删了
[root@localhost ~]# which java
/usr/bin/java
[root@localhost ~]# rm -rf /usr/bin/java
[root@localhost ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
再查看一下:
[root@localhost ~]# rpm -qa | grep -i openjdk
4、把jdk-8u191-linux-x64.tar.gz rz进来
解压到当前就可以:[root@localhost ~]# tar xf jdk-8u191-linux-x64.tar.gz
5、移动到/usr/local下叫java:[root@localhost ~]# mv jdk1.8.0_191/ /usr/local/java
[root@localhost ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
[root@localhost ~]# /usr/local/java/bin/java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
以上操作说明/usr/local/java/bin/java这个路径不再PATH变量中
[root@localhost ~]# vim /etc/profile
添加以下内容
JAVA_HOME=/usr/local/java
PATH=$PATH:$JAVA_HOME/bin
[root@localhost ~]# source /etc/profile
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/java/bin:/root/bin
[root@localhost ~]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
6、把apache-tomcat-8.5.40.tar.gz rz进来
解压:[root@localhost ~]# tar xf apache-tomcat-8.5.40.tar.gz
[root@localhost ~]# mv apache-tomcat-8.5.40 /usr/local/tomcat8
7、运行
[root@localhost local]# /usr/local/tomcat8/bin/startup.sh
[root@localhost local]# netstat -lnpt | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 49504/java
在网页上输入192.168.200.111:8080回车