使用shell脚本搭建httpd服务
#! /bin/bash
#脚本安装HTTP服务
yum -y install wget make gcc pcre-devel apr-devel expat-devel libdb-devel cyrus-sasl-devel openldap-devel apr-util-devel&> /dev/null
wget http://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz &> /dev/null
tar zxf httpd-2.4.52.tar.gz &> /dev/null
cd httpd-2.4.52/ &> /dev/null
./configure --prefix=/usr/local/apache &> /dev/null
make &> /dev/null
make install &> /dev/null
firstip=`ifconfig | grep "netmask" | grep "broadcast" |awk '{ print $2}'` #awk抓取关键ip
sed -i "196aServerName $firstip:80" /usr/local/apache/conf/httpd.conf &> /dev/null #196行插入服务ip:80
/usr/local/apache/bin/apachectl start
systemctl stop firewalld
echo "ok"
实现结果