zoukankan      html  css  js  c++  java
  • 在 CentOS 7 安装 Tomcat

    一、 安装 JDK 8

    1.1 下载 JDK 8

    cd /opt/
    wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
    

    1.2 安装 JDK 8

    tar xzf jdk-8u141-linux-x64.tar.gz
    cd jdk1.8.0_141
    alternatives --install /usr/bin/java java /opt/jdk1.8.0_141/bin/java 2
    alternatives --config java
    

    界面显示内容如下:

    There is 1 program that provides 'java'.
      Selection    Command
    -----------------------------------------------
    *+ 1           /opt/jdk1.8.0_141/bin/java
    Enter to keep the current selection[+], or type selection number:
    

    输入 1 回车

    1.3 设置 javac 和 jar 命令的路径

    alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_141/bin/jar 2
    alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_141/bin/javac 2
    alternatives --set jar /opt/jdk1.8.0_141/bin/jar
    alternatives --set javac /opt/jdk1.8.0_141/bin/javac
    

    1.4 查看是否正确安装

    java -version
    

    1.5 设置环境变量

    export JAVA_HOME=/opt/jdk1.8.0_141
    export JRE_HOME=/opt/jdk1.8.0_141/jre
    export PATH=$PATH:/opt/jdk1.8.0_141/bin:/opt/jdk1.8.0_141/jre/bin
    

    二、安装 Tomcat

    2.1 下载 Tomcat

    wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz
    

    2.2 安装 Tomcat

    tar xzf apache-tomcat-8.5.45.tar.gz
    mv apache-tomcat-8.5.45 /usr/local/tomcat8
    

    2.3 启动 Tomcat

    /usr/local/tomcat8/bin/startup.sh
    

    注意关闭防火墙或放行端口,输入:ip:8080

    参考:

    1. How To Install Java JDK 8 on CentOS 7
    2. wget下载jdk1.8
  • 相关阅读:
    Add source code and doc in maven
    Spring toturial note
    How to add local jar into maven project
    Ubuntu 12.04 下安装 Eclipse
    如何更改linux文件的拥有者及用户组(chown和chgrp)
    20非常有用的Java程序片段
    Java中的Set、List、Map的区别
    Java I/O知识点汇总
    Java I/O流整理
    hadoop2.0集群配置
  • 原文地址:https://www.cnblogs.com/victorbu/p/11542872.html
Copyright © 2011-2022 走看看