• Tomcat安装


    下载安装

    官网下载地址

    把压缩包上传到服务器并解压到指定目录

    # 创建目录
    mkdir
    /usr/local/tomcat cd /usr/local/tomcat # 上传 apache-tomcat-8.5.57.tar.gz rz
    # 解压
    tar xzf apache-tomcat-8.5.57.tar.gz

    配置环境变量

    vim /etc/profile
    set java environment
    JAVA_HOME=/usr/java/jdk1.8.0_291
    JRE_HOME=/usr/java/jdk1.8.0_291/jre
    CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.57
    CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CATALINA_HOME/bin
    PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
    export JAVA_HOME JRE_HOME CATALINA_HOME CLASS_PATH PATH

    使环境变量生效

    source /etc/profile

    添加到系统服务并自启动

    vim /etc/init.d/tomcat
    #!/bin/sh
    # chkconfig: 345 99 10
    # description: Auto-starts tomcat
    # /etc/init.d/tomcatd
    # Tomcat auto-start
    # Source function library.
    # /etc/init.d/functions
    # source networking configuration.
    # /etc/sysconfig/network
    RETVAL=0
    export JAVA_HOME=/usr/java/jdk1.8.0_291
    export JRE_HOME=/usr/java/jdk1.8.0_291/jre
    export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.57
    export CATALINA_BASE=/usr/local/tomcat/apache-tomcat-8.5.57
    start()
    {
            if [ -f $CATALINA_HOME/bin/startup.sh ];
              then
                echo $"Starting Tomcat"
                    $CATALINA_HOME/bin/startup.sh
                RETVAL=$?
                echo " OK"
                return $RETVAL
            fi
    }
    stop()
    {
            if [ -f $CATALINA_HOME/bin/shutdown.sh ];
              then
                echo $"Stopping Tomcat"
                    $CATALINA_HOME/bin/shutdown.sh
                RETVAL=$?
                sleep 1
                ps -fwwu root | grep tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9
                echo " OK"
                # [ $RETVAL -eq 0 ] && rm -f /var/lock/...
                return $RETVAL
            fi
    }
    
    case "$1" in
     start)
            start
            ;;
     stop)
            stop
            ;;
    
     restart)
             echo $"Restaring Tomcat"
             $0 stop
             sleep 1
             $0 start
             ;;
     *)
            echo $"Usage: $0 {start|stop|restart}"
            exit 1
            ;;
    esac
    exit $RETVAL

    授权

    chmod +x /etc/init.d/tomcat

    添加到系统服务并自启动

    chkconfig --add tomcat
    chkconfig tomcat on
    chkconfig --list

    开放端口

    firewall-cmd --zone=public --add-port=8080/tcp --permanent
    firewall-cmd --reload

    测试使用

    service tomcat start
    service tomcat stop
    
    systemctl status tomcat
    systemctl start tomcat systemctl stop tomcat
  • 相关阅读:
    http协议
    web应用
    前端基础-jquery
    jQuery的事件
    2.UML类图基本介绍
    1.设计模式的七大原则
    使用OpenFeign远程调用时请求头处理报错问题
    SpringCloud Config-分布式配置中心
    19. 类加载器详解
    18. 类加载过程详解
  • 原文地址:https://www.cnblogs.com/guofz/p/14779877.html
Copyright © 2020-2023  润新知