/dev/null cat >/etc/yum.repos.d/epel.repo <

小言_互联网的博客

软件包管理-一键安装或卸载httpd2.4.27

489人阅读  评论(0)

安装httpd脚本

#! /bin/bash
# 2018-08-09
# V 1.0 
# ZhuXiaoGuo


# 1. 配置YUM
echo "config yum"

#rm -rf /etc/yum.repos.d/* &>/dev/null
cat >/etc/yum.repos.d/epel.repo <<EOF
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
enabled=1
gpcheck=0

[base]
name=base
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/x86_64/
enabled=1
gpcheck=0

EOF



yum  clean all &> /dev/null
yum  list &> /dev/null
yum  makecache &> /dev/null

echo "yum finish"


# 2. 安装包相应的组件

yum -y groupinstall "Development tools" &> /dev/null
yum -y install apr-devel &> /dev/null
yum -y install apr-util-devel &> /dev/null


# 3. 获取httpd,解包

mkdir /data &> /dev/null

echo "Getting the httpd-2.4.27.tar.gz form network,please wait....."

 wget http://archive.apache.org/dist/httpd/httpd-2.4.27.tar.gz -P /data/
cd /data/
tar -zxvf httpd-2.4.27.tar.gz &> /dev/null

# 编译安装

echo "Begin install httpd server,please wait."
cd httpd-2.4.27

./configure --prefix=/app &> /dev/null  && echo configure finished || { echo configure error; exit; }
make &>/dev/null && echo make finished || { echo make error; exit; }
make install &> /dev/null && echo "httpd service has been finished." || { echo make install error; exit; }

echo "httpd service is starting "

cat >/etc/profile.d/httpdpath.sh<<EOF
PATH=/app/bin:$PATH

EOF
PATH=/app/bin:$PATH

/app/bin/apachectl start &> /dev/null && echo "Apache httpd service is working!" || echo start httpd error

卸载httpd脚本

#! /bin/bash

# 1.  关闭httpd服务

echo "Remove httpd starting "

apachectl stop &> /dev/null && echo "stopping httpd"

# 2. 删除安装目录 /app

rm -rf /app &> /dev/null && echo "deleting  httpd dir."


# 3. 删除源码和PATH变量
echo "deleting  httpd source file."

find / -regex ".*httpd-2.4.27.*" -delete &> /dev/null && echo "deleting httpd path file"
rm -rf /etc/profile.d/httpdpath.sh &>/dev/null && echo "httpd has removed."

转载:https://blog.csdn.net/qq_28674411/article/details/104638486
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场