Centos7安裝JDK+部署Tomcat8

Centos7下JDK+Tomcat的部署:java

1.安裝JDKexpress

 1.1 經過如下命令得到java JDK列表apache

yum -y list java*

 1.2 經過yum安裝JDKvim

yum -y install java-1.8.0-openjdk*

 等待安裝完成centos

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

2.安裝Tomcatapp

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

  下載獲得的壓縮包上傳到centos的/usr/local/目錄jvm

  2.2 經過ls查看壓縮包tcp

 

[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了

相關文章
相關標籤/搜索