zoukankan      html  css  js  c++  java
  • tomcat安装部署完整过程

    1.tomcat安装脚本(installTomcat.sh含开机自启动)

    #!/bin/sh
    
    #定义变量
    basePath=$(cd `dirname $0`;pwd)
    releasePath=/usr/local/jenkins
    echo "$basePath"
    echo "$releasePath"
    
    mkdir -pv $releasePath
    
    function installJDK(){
        echo "install oracleJDK……"
        tar -zxf jdk-8u251-linux-x64.tar.gz
        mv jdk1.8.0_251 $releasePath/jdk1.8.0_251
        echo "orcalejdk1.8.0_251 installed: ok"
    }
    function jenkins_install(){
        sed "$a JENKINS_HOME=/jenkins" /etc/profile
    }
    
    function installTomcat(){
        echo "install Tomcat……"
        tar -zxf apache-tomcat-8.5.59.tar.gz
        mv apache-tomcat-8.5.59 $releasePath/tomcat    
        
        #添加强制关闭tomcat参数配置
        #sed -i '/"$EXECUTABLE" stop/s#exec "$PRGDIR"/"$EXECUTABLE" stop "$@"#exec "$PRGDIR"/"$EXECUTABLE" stop -force "$@"#' $releasePath/tomcat/bin/shutdown.sh
        #在catalina.sh中添加tomcat的安装路径
        sed -i "203iexport CATALINA_BASE=$releasePath/tomcat"  $releasePath/tomcat/bin/catalina.sh
        sed -i "204iexport CATALINA_HOME=$releasePath/tomcat"  $releasePath/tomcat/bin/catalina.sh
        sed -i "205iexport CATALINA_TMPDIR=$releasePath/tomcat"  $releasePath/tomcat/bin/catalina.sh
        #在setclasspath.sh中指定使用的jdk路径
        sed -i "23iexport JAVA_HOME=$releasePath/jdk1.8.0_251" /$releasePath/tomcat/bin/setclasspath.sh
        sed -i "24iexport JRE_HOME=$releasePath/jdk1.8.0_251/jre" /$releasePath/tomcat/bin/setclasspath.sh
        sed -i "25iexport CLASSPATH=.:$releasePath/jdk1.8.0_251/lib/dt.jar:$releasePath/jdk1.8.0_251/lib/tools.jar" /$releasePath/tomcat/bin/setclasspath.sh
        echo "tomcat installed: ok"
        #配置tomcat开机自启
        cp $basePath/restartTomcat.sh /$releasePath/tomcat/bin
        ln -sf $releasePath/tomcat/bin/restartTomcat.sh /etc/rc.d/init.d/tomcat
        chmod +x /etc/rc.d/init.d/tomcat
        chkconfig --list
        cd /etc/rc.d/init.d
        chkconfig --add tomcat
        chkconfig --list tomcat
        #开放tommcat端口
        firewall-cmd --zone=public --add-port=8080/tcp --permanent
        firewall-cmd --reload
        firewall-cmd --list-all | grep ports
        #启动tomcat
        systemctl start tomcat
        
    }
    
    
    
    if [ ! -d $releasePath/jdk1.8.0_251 ];then
        installJDK
    fi
    
    if [ ! -d $releasePath/tomcat ];then
        installTomcat
    fi
    
    if [ "$(cat /etc/profile | grep JENKINS_HOME)" = "JENKINS_HOME=/jenkins" ];then
        echo "已配置jenkins环境变量"
        source /etc/profile
    else
        echo "JENKINS_HOME=/jenkins" >> /etc/profile
        source /etc/profile
    fi

    2.tomcat开机启动脚本(restartTomcat.sh)

    #!/bin/sh
    # chkconfig: 2345 80 90
    # description: tomcat auto start
    # processname:tomcat8.5.89
    
    releasePath=$(cd /usr/local/jenkins/tomcat;pwd)
    
    source /etc/profile
    #重启tomcat
    cd  $releasePath/bin
    sh shutdown.sh
    sh startup.sh

    3.存档跟踪:

  • 相关阅读:
    2019-2020-1 20175315 20175322 20175334 实验五 通讯协议设计
    bfs思路总结
    蓝桥杯-带分数
    Passive WiFi Tracking
    openWRT刷机设置
    研究生若干事
    Dijkstra算法和Floyed算法
    最小生成树prim算法
    无穷大量0x3f3f3f3f
    杭电OJ题目分类
  • 原文地址:https://www.cnblogs.com/schblog/p/13983219.html
Copyright © 2011-2022 走看看