CentOS7 编码编译安装或卸载http2.4.25

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7 编码编译安装或卸载http2.4.25相关的知识,希望对你有一定的参考价值。

待完善

CentOS 7测试

哈哈

#!/bin/bash
#**************************************************************
#Author:                     哈啰
#QQ:                         599503252
#Date:                       2019-08-08
#FileName:                   install_httpd.sh
#URL:                        https://blog.51cto.com/14012942
#Description:                The test script
#Copyright (C):              2019 Copyright ?  站点名称  版权所有
#************************************************************
#set -e
RED="\033[0;31m"
GREEN="\033[0;32m"
NO_COLOR="\033[0m"
PREFIX=/apps/httpd24
SYSCONFDIR=/etc/httpd
SRC=/usr/src
FLAG=$1
CPUS=`cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l`
CORE=`cat /proc/cpuinfo| grep "cpu cores"| uniq | awk ‘print $4‘`
J=$(($CPUS*$CORE))

# 判断是不是root
judge_root() 
    [ $(id -u) != "0" ] &&  echo -e "$REDError:$NO_COLOR You must be root to run this script."; exit 1;    


# download 
download_source() 
    cd
    yum install wget -y
    #wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.bz2
    # wget https://ftp.osuosl.org/pub/blfs/conglomeration/httpd/httpd-2.4.25.tar.bz2
    wget https://ftp.bit.nl/apache/httpd-2.4.25.tar.bz2
    if [ ! "$?" -eq 0 ];then
        echo "download failed!"
        exit 1
    fi


# install
install() 
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    yum install gcc openssl-devel pcre-devel apr-devel apr-util-devel libnghttp2-devel ncurses-devel  lbzip2  bzip2 -y
    tar xf httpd-2.4.25.tar.bz2 -C $SRC/
    cd $SRC/httpd-2.4.25
    ./configure     --prefix=$PREFIX     --sysconfdir=$SYSCONFDIR     --enable-http2     --disable-auth-basic     --enable-ssl     --enable-so
    make -j $J
    make install
    echo "PATH=$PREFIX/bin:$PATH" >> /etc/profile.d/env.sh
    source /etc/profile.d/env.sh


# test_web
test_web() 
    apachectl start
    ss -ltn | grep -q :80
    [ "$?" -eq 0 ] && echo -e "$GREENMay be web server is ok! \n If not ok,please check selinux and firewalld status.$NO_COLOR" ||         echo -e "$REDERROR,Please check the web server.$NO_COLOR"


remove_httpd() 
    source /etc/profile.d/env.sh
    apachectl stop
    rm -rf $PREFIX $SYSCONFDIR $SRC/httpd-2.4.25
    sed -i ‘/^PATH/d‘ /etc/profile.d/env.sh


judge_uninstall()
if [ "$FLAG" = "uninstall" ];then
    remove_httpd
    exit 0
fi


main() 
    judge_uninstall
    judge_root
    download_source
    install
    test_web


main

以上是关于CentOS7 编码编译安装或卸载http2.4.25的主要内容,如果未能解决你的问题,请参考以下文章

http协议--Apache-Httpd服务基本配置-rpm安装-编译安装(HTTP2.2,HTTP2.4)

centos7编译安装的php7怎么卸载 解决cenos 编译安装软件后怎么卸载问题

编译安装http2.4,实现可以正常访问

centos7安装python 与卸载python

Linux yum仓库搭建http2.4源码编译和文件系统创建挂载

centos7 怎么卸载软件php