虚拟机centos6下安装jdk8以及tomcat

VM虚拟机centos6下安装jdk8以及tomcat

1.下载安装包

jdk-8u261-linux-x64.tar.gz
虚拟机centos6下安装jdk8以及tomcat_第1张图片

2.解压包

tar -zxvf jdk-8u261-linux-x64.tar.gz 

3.配置环境

vi /etc/profile

/usr/local/jdk8/jdk1.8.0_261 配置需要自己实际的路径

 export JAVA_HOME=/usr/local/jdk8/jdk1.8.0_261
 export JRE_HOME=${JAVA_HOME}/jre
 export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
 export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
 export PATH=$PATH:${JAVA_PATH}
export JAVA_HOME=/usr/java/jdk1.8.0_181
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib

两次配置的对比:这样配置才成功

#export JAVA_HOME=/usr/local/jdk7/jdk1.8.0_261
#export JRE_HOME=${JAVA_HOME}/jre
#export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
#export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
#export PATH=$PATH:${JAVA_PATH}
export JAVA_HOME=/usr/local/jdk7/jdk1.8.0_261
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib

4.重启配置生效

source /etc/profile

虚拟机centos6下安装jdk8以及tomcat_第2张图片

5.验证安装成功与否

#验证
root@localhost /]# java -version
-bash: /usr/local/jdk8/jdk1.8.0_261/bin/java: cannot execute binary file
#查看操作系统
[root@localhost /]# uname -a
Linux localhost.localdomain 2.6.32-358.el6.i686 #1 SMP Thu Feb 21 21:50:49 UTC 2013 i686 i686 i386 GNU/Linux

原来我安装的版本是64位,操作系统是32,只能重新安装

tomcat

1.同样下载解压

虚拟机centos6下安装jdk8以及tomcat_第3张图片

2.配置环境变量

vim /etc/profile.d/tomcat.sh
#添加一下内容
CATALINA_BASE=/usr/local/tomcat/apache-tomcat-7.0.70
PATH=$CATALINA_BASE/bin:$PATH
export PATH CATALINA_BASE

3.重启配置

source  /etc/profile.d/tomcat.sh

4.启动tomcat’

[root@localhost bin]# catalina.sh start
Using CATALINA_BASE:   /usr/local/tomcat/apache-tomcat-7.0.70
Using CATALINA_HOME:   /usr/local/tomcat/apache-tomcat-7.0.70
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-7.0.70/temp
Using JRE_HOME:        /usr/local/jdk8/jdk1.8.0_261/jre
Using CLASSPATH:       /usr/local/tomcat/apache-tomcat-7.0.70/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-7.0.70/bin/tomcat-juli.jar
Tomcat started.
#查看进程端口
netstat -tpln | grep 7764
tcp        0      0 :::8009                     :::*                        LISTEN      7764/java           
tcp        0      0 :::8080                     :::*                        LISTEN      7764/java           
tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN      7764/java    

5.注意开放端口

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [24:2336]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8009 -j ACCEPT
#注意此处的端口,一定在下边两行的上边,否则配置无效
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
`![在这里插入图片描述](https://img-blog.csdnimg.cn/20200802205156655.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM3NDAwMDk2,size_16,color_FFFFFF,t_70)


你可能感兴趣的:(Linux,Java)