龙空技术网

shell 日常小练习——安装httpd,安装yum源

贝利虎教育 465

前言:

如今姐妹们对“yum安装httpd”大约比较珍视,姐妹们都想要分析一些“yum安装httpd”的相关内容。那么小编在网上收集了一些对于“yum安装httpd””的相关知识,希望你们能喜欢,同学们快快来学习一下吧!

1.安装httpd

#!/usr/bin/bash

getway=192.168.1.1

ping -c1 &>/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 $getway &>/dev/null;then

echo "check dns..."

else

echo "check ip address!"

fi

2.安装yum源

#!/usr/local/bash

yum_server=192.168.234.137

#注意在print的时候外面的引号需要单引号

os_version=`cat /etc/redhat-release |awk '{print $4}'|awk -F"." '{print $1."."$2}'`

[ -d /etc/yum.repos.d ] || mkdir /etc/yum.repos.d/bak

mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

case "$os_version" in

7.4)

cat >/etc/yum.repos.d/centos7.4 <<-EOF

[centos7.4]

name=centos7.4

baseurl=

gpgcheck=0

EOF

echo "7.4 yum configure..."

;;

6.8)

curl -o /eetc/yum.repos.d/centos6u8.repo

;;

*)

echo "error"

esac

标签: #yum安装httpd