局域网下一键自动编译httpd服务并设置为开机启动提供yum仓库

#!/bin/bash

#自动编译httpd2.4.25

#查看本地版本
Version=sed -rn 's@(^.*) ([0-9]+)(\..*)@\2@p' /etc/redhat-release

#下载网络源
wget http://192.168.146.147/IOS/Myrepo.repo
#初始化本地仓库
yum clean all &> /dev/null
yum repolist &> /dev/null
#下载httpd依赖环境
yum install -y openssl-devel pcre-devel gcc apr-util-devel &> /dev/null
#下载网络httpd包
wget http://192.168.146.147/IOS/httpd-2.4.25.tar.bz2 &>/dev/null
#解压
tar -xvf httpd-2.4.25.tar.bz2 &> /dev/null
cd /etc/yum.repos.d/httpd-2.4.25
#编译
./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-ssl --enable-so &> /dev/null
#汇编
make && make install &> /dev/null

#设置开自启httpd
touch /var/lock/subsys/local
echo “touch /var/lock/subsys/local” >> /etc/rc.local
echo “/apps/httpd24/bin/apachectl” >> /etc/rc.local
chmod +x /etc/rc.local
echo “export PATH=/apps/httpd24/bin:$PATH” >> /etc/profile.d/welcome.sh
/apps/httpd24/bin/apachectl start
apachectl start

#永久关闭firewalld和selinux
sed -ri.bak ‘s/^SELINUX=.*/SELINUX=disabled/’ /etc/selinux/config
setenforce 0

if [ $Version -ge 7 ];then
systemctl stop firewalld.service;systemctl disable firewalld.service
else
chkconfig iptables off;service iptables stop
fi

#重启测试
reboot

#加载镜像文件到本地同步到OS:
for i in /sys/class/scsi_host/host*/scan;do
echo ‘- - -’ > $i;
done

#挂载光盘镜像并链接至web界面,写入/etc/fstab文件中实现永久挂载
mount /dev/sr0 /apps/http24/htos

#移除默认Apache欢迎界面
mv /etc/httpd/conf.d/welcome.conf{,.bak}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章