zoukankan      html  css  js  c++  java
  • shell一键部署nginx+tomcat

    1.首先拉取环境  tomcat需要用到jdk环境

    提前准备好nginx源码包,放于指定目录下

    vim test.sh
    
    #!/bin/bash
    yum -y install gcc gcc-c++ zlib-devel pcre-devel
    tar zxf nginx-1.16.1.tar.gz
    cd nginx-1.16.1 && ./configure && make && make install
    cd /root && rpm -ivh jdk-8u20-linux-x64.rpm
    tar zxf apache-tomcat-7.0.96.tar.gz
    cp -r apache-tomcat-7.0.96 /opt/tomcat
    /usr/local/nginx/sbin/nginx
    /opt/tomcat/bin/startup.sh
    

      判断nginx

    shulian=`cat /usr/local/nginx/conf/nginx.conf|grep 'proxy_pass   http://192.168.11.128:8080;'|wc -l`
    if [ $shulian -ne 1 ];then
    sed -i  's/index.htm;$/index.jsp;/' /usr/local/nginx/conf/nginx.conf
    sed -i  '/404.html;/alocation ~ \.jsp$ {' /usr/local/nginx/conf/nginx.conf
    sed -i  '/location ~ \.jsp$ {/aproxy_pass   http://192.168.11.128:8080;' /usr/local/nginx/conf/nginx.conf
    sed -i  '/proxy_pass   http://192.168.11.128:8080;/a}' /usr/local/nginx/conf/nginx.conf
    fi
    

      判断是否在jdk环境

    cishu=`cat /etc/profile|grep 'JAVA_HOME'|wc -l`
    if [ $cishu -ne 4 ];then
    echo -e 'export JAVA_HOME=/usr/java/jdk1.8.0_20
    export JAVA_BIN=/usr/java/jdk1.8.0_20/bin
    export PATH=$PATH:$JAVA_HOME/bin
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' >>/etc/profile
    fi

    source /etc/profile

      tomcat下载路径

    wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
    

      2.访问ip,后缀添加index.jsp

     successful test!!!

  • 相关阅读:
    nowcoderD Xieldy And His Password
    Codeforces681D Gifts by the List
    nowcoder80D applese的生日
    Codeforces961E Tufurama
    Codeforces957 Mahmoud and Ehab and yet another xor task
    nowcoder82E 无向图中的最短距离
    nowcoder82B 区间的连续段
    Codeforces903E Swapping Characters
    Codeforces614C Peter and Snow Blower
    Codeforces614D Skills
  • 原文地址:https://www.cnblogs.com/security-guard/p/12001073.html
Copyright © 2011-2022 走看看