• CentOS 安装tomcat


    1、确保JDK已经安装,版本在1.8以上

    2、到网管下载安装

    wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.tar.gz
    
    tar -xzvf apache-tomcat-9.0.14.tar.gz

    3、查看tomcat配置

    [root@bigdata-senior01 bin]# ./catalina.sh version
    Using CATALINA_BASE:   /opt/apache-tomcat-9.0.14
    Using CATALINA_HOME:   /opt/apache-tomcat-9.0.14
    Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.14/temp
    Using JRE_HOME:        /home/java/jdk1.8.0_172/jre
    Using CLASSPATH:       /opt/apache-tomcat-9.0.14/bin/bootstrap.jar:/opt/apache-tomcat-9.0.14/bin/tomcat-juli.jar
    Server version: Apache Tomcat/9.0.14
    Server built:   Dec 6 2018 21:13:53 UTC
    Server number:  9.0.14.0
    OS Name:        Linux
    OS Version:     3.10.0-693.el7.x86_64
    Architecture:   amd64
    JVM Version:    1.8.0_172-b11
    JVM Vendor:     Oracle Corporation

    4、配置端口,开通防火墙端口

    #可以选择修改默认的8080端口
    [root@bigdata-senior01 apache-tomcat-9.0.14]# vi conf/server.xml 
    
        <Connector port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />
        <!-- A "Connector" using the shared thread pool-->
        <!--
        <Connector executor="tomcatThreadPool"
                   port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />
        -->
    
    
    打开防火墙
    [root@bigdata-senior01 bin]# firewall-cmd --add-port=8080/tcp --permanent
    success
    [root@bigdata-senior01 bin]# firewall-cmd --reload
    success

    5、配置管理用户

    [root@bigdata-senior01 apache-tomcat-9.0.14]# vi conf/tomcat-users.xml 
    
    #加入管理用户
      <role rolename="manager-gui"/>
      <user username="admin" password="123456" roles="manager-gui"/>
    #修改管理页面的ip访问许可
    [root@bigdata-senior01 apache-tomcat-9.0.14]# vi  webapps/manager/META-INF/context.xml 
    
    <Context antiResourceLocking="false" privileged="true" >
      <Valve className="org.apache.catalina.valves.RemoteAddrValve"
             allow="192.d+.d+.d+|::1|0:0:0:0:0:0:0:1" />   #原本是127,即只允许本机访问
      <Manager sessionAttributeValueClassNameFilter="java.lang.(?:Boolean|Integer|Long|Number|String)|org.apache.catalina.filters.CsrfPreventionFilter$LruCache(?:$1)?|java.util.(?:Linked)?HashMap"/>
    </Context>

    6、测试tomcat

    7、发布webapp

    将war包或者整个webapp放入tomcat的webapps目录下即可访问,但是要跟上目录名,如果需要在ip或者域名后面直接访问,需要配置conf目录下的server.xml
    [root@bigdata-senior01 apache-tomcat-9.0.14]# vi conf/server.xml 
    ... ...
          <Host name="localhost"  appBase=""
                unpackWARs="true" autoDeploy="true">
    
          <Context path="" docBase="/opt/apache-tomcat-9.0.14/webapps/bus" debug="0" privileged="true" />
  • 相关阅读:
    LightOj1054
    LightOj1028
    Docker仓库(转载)
    Dockerfile(转载)
    Docker存储卷(转载)
    容器虚拟化网络和Docker容器网络(转载)
    Docker镜像管理基础(转载)
    Docker基础用法(转载)
    docker容器技术基础入门(转载)
    Redis 3种安装部署方式
  • 原文地址:https://www.cnblogs.com/asker009/p/10328410.html
Copyright © 2020-2023  润新知