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

本文档详细介绍了如何在Linux环境下使用脚本快速安装和卸载httpd2.4.27服务器。通过提供的安装脚本,可以一键完成httpd的部署,而卸载脚本则帮助用户便捷地移除httpd服务。
摘要由CSDN通过智能技术生成

安装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."
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值