安装apache
vim install_apache.sh
#!/usr/bin/bash
ping -c1 www.baidu.com &>/dev/null #检测网通不通,不通直接退出
if [ $? -eq 0 ];then
echo "connect:unreachable"
exit
fi
yum -y install httpd
systemctl start httpd
systemctl enable httpd
firewall -cmd --permanent -add-service=http
firewall -cmd --permanent -add-service=https
firewall -cmd --reload
sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
setenforce 0
vim install_apache2.sh
#!/usr/bin/bash
gateway=192.168.122.1
ping -c1 www.baidu.com &>/dev/null
if [ $? -eq 0 ];then
yum -y install httpd
systemctl start httpd
systemctl enable httpd
firewall -cmd --permanent -add-service=http
firewall -cmd --permanent -add-service=https
firewall -cmd --reload
sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
setenforce 0
elif ping -c1 $gateway &>/dev/null;then#ping网关,这里开始排查ping不通baidu的网络原因
echo "check dns..."
else
echo "check ip address!"
fi
yum配置源
#!/usr/bin/bash
#yum config
yum_server=10.18.40.100
os_version=`cat /etc/redhat-release |awk '{print $4}' \
|awk -F"." '{print $1"."$2}'`#其中-F"."是以.作为分隔符
[ -d /etc/yum.repos.d ] || mkdir /etc/yum.repos.d/bak #如果/etc/yum.repos.d不存在 则创建 /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
if [ "$os_version" = "7.3" ];then
cat >/etc/yum.repos.d/centos7u3.repo <<-EOF
[centos7u3]
name=centos7u3
baseurl=ftp://$yum_server/centos7u3
gpgcheck=0
EOF
echo "7.3 yum configure"
elif [ "$os_version" = "6.8" ];then
curl -o /etc/yum.repos.d/centos6u8.repo ftp://$yum_server/centos6u8.repo
elif [ "$os_version" = "5.9" ];then
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
else
echo "error"
fi