1.jdk 1.8
#系统版本
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
#安装之前先查看一下有无系统自带jdk
rpm -qa |grep java rpm -qa |grep jdk rpm -qa |grep gcj
#如果有,卸载
rpm -qa | grep java | xargs rpm -e --nodeps
#yum安装1.8.0版本openjdk
[root@localhost ~]# yum install java-1.8.0-openjdk* -y
#查看版本
[root@localhost ~]# java -version openjdk version "1.8.0_161" OpenJDK Runtime Environment (build 1.8.0_161-b14) OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
#默认jre jdk 安装路径是/usr/lib/jvm 下面
#配置jdk环境变量
vim /etc/profile #set java environment export JAVA_HOME=/usr/lib/jvm/java export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar export PATH=$PATH:$JAVA_HOME/bin
#退出编辑并保存
:wq!
#使配置生效
source /etc/profile
#查看变量
[root@localhost ~]# echo $JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64 [root@localhost ~]# echo $CLASSPATH .:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/lib/dt.jar:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/lib/tools.jar
2.tomcat 8
#进入指定路径
cd /root wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.34/bin/apache-tomcat-8.5.34.tar.gz
#解压压缩包
tar -zxvf apache-tomcat-8.5.34.tar.gz
#更改名称
mv apache-tomcat-8.5.34 tomcat-8
#启动tomcat
cd /root/tomcat-8/bin/ ./startup.sh