源码安装apache脚本
#!/bin/bash
#By:zhaocheng
#Date:2019-01-18
[ -d /media/cdrom ] || mkdir /media/cdrom
[ -d /media/cdrom/Packages ] || mount /dev/cdrom /media/cdrom &> /dev/null
echo "正在挂载光盘镜像,请耐心等待..."
#修改yum仓库配置文件
cd /etc/yum.repos.d/
[ -d bak ] || mkdir bak
mv *.r* bak
cp bak/*M* .
cat << EOF > CentOS-Media.repo
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
cd /media/cdrom/
rpm --import *K*
yum -y clean all &> /dev/null
yum makecache &> /dev/null
echo "本地yum仓库完成,正在配置源码编译环境..."
tar xf /root/httpd-2.4.37.tar.gz -C /usr/src
cd /usr/src/httpd-2.4.37/
./configure --prefix=/usr/local/httpd &> /dev/null
yum -y install apr* &> /dev/null
yum -y install pcre* &> /dev/null
cd /usr/src/httpd-2.4.37/
./configure --prefix=/usr/local/httpd &> /dev/null
make &> /dev/null
make install &> /dev/null
cd /usr/local/httpd/conf/
cp httpd.conf httpd.conf.bak
cat << EOF >> /usr/local/httpd/conf/httpd.conf
ServerName www.example.com:80
EOF
#启动apache
/usr/local/httpd/bin/apachectl start
yum -y install lynx &> /dev/null
lynx 127.0.0.1