CentOS7 脚本一键源码编译安装或卸载http2.4.25
admin
2023-03-01 21:42:05
0

待完善
CentOS 7测试

哈哈

#!/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

相关内容

热门资讯

邮轮暴发汉坦病毒疫情,世卫确认... 据凤凰卫视报道,大西洋邮轮“洪迪厄斯”号暴发汉坦病毒疫情,世界卫生组识5月7日证实,船上共有5宗确诊...
内蒙古赤峰两村半个多世纪的土地... 澎湃新闻记者 王选辉争议土地大北叉沟。本文图均为 受访者 提供备受社会关注的“赤峰两村半个多世纪的土...
冥王星5月8日开启逆行 持续约... 被“逐出”太阳系大行星序列的冥王星5月8日将结束顺行,开启为期约5个月的逆行。这也是2026年冥王星...
夸大AI功能被起诉 苹果2.5... 当地时间5月5日,因夸大AI系统“苹果智能”(Apple Intelligence)的能力,误导数百...
学习机直播乱象调查:主播打北大... 极目新闻记者 刘闪 何佳仪打开短视频平台,各类学习机测评直播间随处可见。一些自诩自己是“老师”的主播...
即日起,郑州“错峰加油”有优惠... 进入5月,又到了郑州臭氧污染频发的季节,记者从郑州市生态环境局移动源污染监管处了解到,为减少臭氧污染...
汗水写热爱 篮球致青春 成人组1VS1比赛。河南日报全媒体记者 黄晖 摄“非常高兴能够参加这种全民赛事,也希望以后能够有更多...
荷兰六六民主党全国办公室遭爆炸... 荷兰警方7日说,荷兰执政党之一的六六民主党位于海牙的全国办公室当晚遭爆炸物袭击,造成建筑受损,无人受...
樱花树油烟机总是开不了怎么回事 电源问题。先检查电源是否未插上或是否电,若没有,将它重新插好,等待来电后测试,检查开不了机的问题是否...
燃气灶打火后一会就灭是什么原因 原因可能是电池没有电了,所以一开始能够打着火,但是燃烧了一会儿又熄灭了,这种情况下可以尝试更换一节新...