重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

CentOS7脚本一键源码编译安装或卸载http2.4.25-创新互联

待完善
CentOS 7测试

从事成都二枢机房,服务器租用,云主机,虚拟主机,域名与空间,CDN,网络代维等服务。

哈哈

#!/bin/bash
#**
#Author: 哈啰
#QQ: ×××
#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 "${RED}Error:${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 "${GREEN}May be web server is ok! \n If not ok,please check selinux and firewalld status.${NO_COLOR}" || \
echo -e "${RED}ERROR,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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻名称:CentOS7脚本一键源码编译安装或卸载http2.4.25-创新互联
网站URL:http://cqcxhl.cn/article/dpspco.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP