一、安装Java 7

1 把下载好的jdk-7u79-linux-x64.tar.gz上传到服务器的/usr/local/下

 

2 解压缩并重命名

# cd /usr/local/

# tar -zxvf jdk-7u79-linux-x64.tar.gz

# mv jdk1.7.0_79/ jdk7/

 

3 将java相关的变量添加到profile文件中

# vi /etc/profile

export JAVA_HOME=/usr/local/jdk7

exportCLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin

 

4 使profile文件生效

# source /etc/profile

 

5 验证

# java -version

java version "1.7.0_79"

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02,mixed mode)

 

二、安装Tomcat 7

1把下载好的apache-tomcat-7.0.65.tar.gz上传到服务器的/usr/local/下

 

2解压缩并重命名

#cd /usr/local/

#tar -zxvf apache-tomcat-7.0.65.tar.gz

#mv apache-tomcat-7.0.65 tomcat

 

3开放8080端口

#firewall-cmd --query-port=8080/tcp

no

#firewall-cmd --add-port=8080/tcp

success

#firewall-cmd --query-port=8080/tcp

yes

 

4启动tomcat服务

#cd /usr/local/tomcat/bin/

#./startup.sh

UsingCATALINA_BASE:   /usr/local/tomcat

UsingCATALINA_HOME:   /usr/local/tomcat

UsingCATALINA_TMPDIR: /usr/local/tomcat/temp

UsingJRE_HOME:        /usr/local/jdk7

UsingCLASSPATH:      /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcatstarted.

 

5在远程Windows主机上打开tomcat主页

CentOS 7安装Tomcat 7_jar