1. 程式人生 > >Centos7安裝JDK+部署Tomcat8

Centos7安裝JDK+部署Tomcat8

等待 訪問 copy version alt .com rmi gree http

Centos7下JDK+Tomcat的部署:

1.安裝JDK

 1.1 通過以下命令獲得java JDK列表

yum -y list java

 1.2 通過yum安裝JDK

yum -y install java-1.8.0-openjdk*

 等待安裝完成

****通過yum默認安裝的路徑為/usr/lib/jvm/java-版本號(如/usr/lib/jvm/java-1.8.0)****

2.安裝Tomcat

  2.1.在Tomcat官網下載Tomcat8的gz壓縮包(附:https://tomcat.apache.org/download-80.cgi)

技術分享圖片

  下載得到的壓縮包上傳到centos的/usr/local/

目錄

  2.2 通過ls查看壓縮包

[root@VM_0_9_centos jvm]# cd /usr/local/
[root@VM_0_9_centos local]# ls
apache-tomcat-8.5.33.tar.gz  etc    include  lib64    qcloud  share  tomcat
bin                          games  lib      libexec  sbin    src

  2.3 解壓並通過mv移動到tomcat文件夾

[root@VM_0_9_centos local]# tar xvf apache-tomcat-8.5
.33.tar.gz [root@VM_0_9_centos local]# mv apache-tomcat-8.5.33 /usr/local/tomcat/

  2.4 配置jdk到tomcat

[root@VM_0_9_centos local]# vim /usr/local/tomcat/bin/startup.sh
[root@VM_0_9_centos local]# vim /usr/local/tomcat/bin/shutdown.sh

  通過vim將以下代碼插入到startup.sh和shutdown.sh

export JAVA_HOME=/usr/lib/jvm/java-1.8.0
export TOMCAT_HOME
=/usr/local/tomcat export CATALINA_HOME=/usr/local/tomcat export CLASS_PATH=$JAVA_HOME/bin/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tool.jar export PATH=$PATH:/usr/lib/jvm/java-1.8.0/bin:/usr/local/tomcat/bin

  完成之後是這樣的

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
# -----------------------------------------------------------------------------

# Better OS/400 detection: see Bugzilla 31132
export JAVA_HOME=/usr/lib/jvm/java-1.8.0
export TOMCAT_HOME=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export CLASS_PATH=$JAVA_HOME/bin/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tool.jar
export PATH=$PATH:/usr/lib/jvm/java-1.8.0/bin:/usr/local/tomcat/bin

os400=false
case "`uname`" in
OS400*) os400=true;;
esac

# resolve links - $0 may be a softlink
PRG="$0"

  2.5 這時候就已經配置好了,最後將tomcat的8080端口號修改為tcp/ip默認的80端口

[root@VM_0_9_centos local]# vim /usr/local/tomcat/conf/server.xml
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

改為

    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

  2.6 啟動tomcat

[root@VM_0_9_centos local]# /usr/local/tomcat/bin/startup.sh

完成後,直接輸入ip/域名就能訪問tomcat了

技術分享圖片

Centos7安裝JDK+部署Tomcat8