Get the App
SLTechnology News&Howtos  ›  Servers  › 

CentOS7 script one-click source code compilation, installation or uninstallation of http2.4.25

Shulou Source: shulou.com Published: 2022-06-02 10:49:09 11月15日 Update

To be improved

CentOS 7 Test

Ha ha

#! / bin/bash

# * *

# Author: Hello

# QQ: × × ×

# Date: 2019-08-08

# FileName: install_httpd.sh

# URL: https://blog.51cto.com/14012942

# Description: The test script

# Copyright (C): 2019 Copyright ©site name. All rights reserved.

# *

# set-e

RED= "\ 033 [0ter31m"

GREEN= "\ 033 [0x 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}'

Junk $(${CPUS} * ${CORE}))

Judge whether it is root or not.

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.bz2wget https://ftp.bit.nl/apache/httpd-2.4.25.tar.bz2if [! "$?"-eq 0]; then echo "download failed!" Exit 1fi

}

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

Tags: Name copyright copyright site test source code script one click compile Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Apple Shulou Technology Microsoft OPPO Reno