Linux(CentOS 6.7)安装JDK 1.8及tomcat 8

时间:2022-09-18 10:06:21

  下面将介绍如何在Linux(CentOS 6.7)系统上,安装JDK 1.8及tomcat 8。

  所需软件包:

  1) jdk-8u65-linux-x64.tar.gz

    下载地址:http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.tar.gz

  2) apache-tomcat-8.0.28.tar.gz

    下载地址:http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.0.28/bin/apache-tomcat-8.0.28.tar.gz

  相关步骤:

  1. 进入root家目录,将这两个包复制到 /usr/local/ 目录下,分别解压

    [root@localhost ~]# cp jdk-8u65-linux-x64.tar.gz apache-tomcat-8.0.28.tar.gz /usr/local/

    tar zxf jdk-8u65-linux-x64.tar.gz

    tar zxf apache-tomcat-8.0.28.tar.gz

  2. 配置相关环境变量

    [root@localhost bin]# cd /usr/local/apache-tomcat-8.0.28/bin
    [root@localhost bin]# vi setclasspath.sh

    在# Make sure prerequisite environment variables are set 后面加上:
    export JAVA_HOME=/usr/local/jdk1.8.0_65
    export JRE_HOME=/usr/local/jdk1.8.0_65/jre

  3. 启动,停止tomcat

    [root@localhost bin]# ./startup.sh
    Using CATALINA_BASE:   /usr/local/apache-tomcat-8.0.28
    Using CATALINA_HOME:   /usr/local/apache-tomcat-8.0.28
    Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.28/temp
    Using JRE_HOME:        /usr/local/jdk1.8.0_65/jre
    Using CLASSPATH:       /usr/local/apache-tomcat-8.0.28/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.28/bin/tomcat-juli.jar
    Tomcat started.

    Linux(CentOS 6.7)安装JDK 1.8及tomcat 8
    [root@localhost bin]# ./shutdown.sh
    Using CATALINA_BASE:   /usr/local/apache-tomcat-8.0.28
    Using CATALINA_HOME:   /usr/local/apache-tomcat-8.0.28
    Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.28/temp
    Using JRE_HOME:        /usr/local/jdk1.8.0_65/jre
    Using CLASSPATH:       /usr/local/apache-tomcat-8.0.28/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.28/bin/tomcat-juli.jar

  至此,JDK 1.8及tomcat 8安装完毕。