• apache安裝脚本


    #!/bin/bash
    ######
    #Autho: tyzh
    #Date: 2020-06-17
    ######


    ####安装前检查####
    CurrentVersion=`httpd -v|head -1`
    colorGreen="33[32m"
    colorRed="33[31m"
    colorEnd="33[0m"
    ###判断是否有运行的httpd服务#####
    netstat -tnlp|grep httpd
    if [ $? = 1 ];then
    echo "当前版本为:$CurrentVersion"
    read -p "请再次确认,是否要安装httpd2.4.43(yes/no)? $colorend" INPUT
    INPUT=`echo $INPUT|tr 'A-Z' 'a-z'`
    case $INPUT in
    n|no)
    exit 1
    ;;
    y|yes)
    echo "安装httpd2.4.43准备安装......"
    ;;
    *)
    echo 'Input fales,plese input yes or no'
    ;;
    esac
    else
    echo "警告需要先停掉目前服务,再继续安装,apachectl -k stop"
    read -p "请再次确认,是否要安装httpd2.4.43(yes/no)?" INPUT
    INPUT=`echo $INPUT|tr 'A-Z' 'a-z'`
    case $INPUT in
    n|no)
    exit 1
    ;;
    y|yes)
    echo "安装httpd2.4.43准备安装......"
    apachectl -k stop
    ;;
    *)
    echo 'Input fales,plese input yes or no'
    ;;
    esac
    fi
    sleep 5s
    ####安装依赖####
    echo -e "$colorGreen yilai install starting.....$colorEnd"
    yum -y install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
    if [ $? = 0 ];then
    echo -e "$colorGreen yilai install finished.....$colorEnd"
    else
    echo -e "$colorRed yilai install false,please check your repo source!$colorEnd"
    sleep 10s
    exit 1
    fi
    sleep 5s
    ######添加apache用户,组#####
    group apache
    useradd -r -s /sbin/nologin -d /var/www/html apache
    ####安装httpd2.4.43包####
    echo -e "$colorGreen httpd-2.4.43 starting......$colorEnd"
    wget https://mirror.bit.edu.cn/apache//httpd/httpd-2.4.43.tar.bz2
    tar xvf httpd-2.4.43.tar.bz2 -C /usr/local/src
    cd /usr/local/src/httpd-2.4.43/
    ###配置httpd###
    ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-ssl
    ###编译并安装####
    make -j 2 && make install
    echo -e "$colorGreen httpd-2.4.43 finished......$colorEnd"
    ####httpd启动环境配置,启动###
    echo PATH=/usr/local/httpd/bin:$PATH > /etc/profile.d/httpd.sh
    source /etc/profile.d/httpd.sh
    sed -i 's/User daemon/User apache/' /etc/httpd/httpd.conf
    sed -i 's/Group daemon/Group apache/' /etc/httpd/httpd.conf
    ###检查安装文件####
    apachectl -t
    ####启动服务####
    apachectl -k restart
    echo 'httpd 服务已经启动.......'
    echo $CurrentVersion

  • 相关阅读:
    简直不敢相信...
    halcon 保存Region [原创]
    VS2015 下载链接
    C#【数据转换】十进制yte[]相互转换
    C# 复制窗体问题完美解决办法
    TextBox 保持固定长度,添加新行滚动到最后,跨线程。
    mysql isnull
    C#跨线程访问控件[我的记录]
    C# 常用类-IO-ClassExcelExport
    C# 常用类-IO-ClassXML
  • 原文地址:https://www.cnblogs.com/yazhan/p/13155716.html
Copyright © 2020-2023  润新知