1,解压jdk包,跟apache的gcc gcc-c++的底层源码差不多
卸载rpm安装的jdk软件包
方法 1
[root@localhost ~]# rpm -qa | grep -i openjdk
java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.141-2.6.10.5.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.131-11.b12.el7.x86_64
java-1.7.0-openjdk-1.7.0.141-2.6.10.5.el7.x86_64
[root@localhost ~]# rpm -e java-1.8.0-openjdk --nodeps //卸载不了的软件包加 --nodeps解除依赖关系
[root@localhost ~]# rpm -e java-1.7.0-openjdk-headless --nodeps
[root@localhost ~]# rpm -e java-1.8.0-openjdk-headless --nodeps
[root@localhost ~]# rpm -e java-1.7.0-openjdk --nodeps
方法 2
[root@localhost ~]# which java
/usr/bin/which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@localhost ~]# rm -rf /usr/bin/java
[root@localhost ~]# java -version
2,jdk的安装
[root@nginx ~]# tar xf jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# mv jdk1.8.0_191/ /usr/local/java //移动到路径取名叫java
[root@localhost ~]# java -version //查看显示没有环境变量
bash: java: 未找到命令...
[root@localhost ~]# vim /etc/profile //添加环境变量
在最下面加这个环境变量
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin
[root@localhost ~]# echo $PATH //一共有的查看环境变量
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# source /etc/profile //从新加载刚刚配置的环境变量
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/java/bin //之后就可以看到我们刚刚配置的环境变量了
[root@localhost ~]# java -version //安装好的jdk就出来了
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)
3,Tomcat的安装
[root@localhost ~]# tar xf apache-tomcat-8.5.40.tar.gz //解压
[root@localhost ~]# mv apache-tomcat-8.5.40 /usr/local/tomcat8 //移动到对应路径
[root@localhost ~]# ls /usr/local/tomcat8/bin/
bootstrap.jar configtest.bat setclasspath.sh tomcat-native.tar.gz
catalina.bat configtest.sh shutdown.bat tool-wrapper.bat
catalina.sh daemon.sh shutdown.sh tool-wrapper.sh //这里面就是tomcat的所有文件,startup.sh 开启脚本 shutdown.sh 关闭脚本
catalina-tasks.xml digest.bat startup.bat version.bat
commons-daemon.jar digest.sh startup.sh version.sh
commons-daemon-native.tar.gz setclasspath.bat tomcat-juli.jar
[root@localhost ~]# netstat -lnpt | grep :8080 //汤姆猫的端口的 8080
tcp6 0 0 :::8080 :::* LISTEN 4312/java
之后就可以在浏览器访问了,192.168.200.111:8080