CentOS7配置本地yum源, 局域网内其他机器也一样,修改baseurl Linux教程




/opt

wget http://mirrors.njupt.edu.cn/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso


mkdir  /home/iso/ 

mount -o loop CentOS-7-x86_64-DVD-2009.iso /home/iso/


-配置本地yum源

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

mkdir /etc/yum.repos.d

vi /etc/yum.repos.d/CentOS-local.repo

#本源的名字(不能和其他重复)
[base-local]
name=CentOS7-local
#这里的IP根据现场的yum源决定
#baseurl=http://44.135.8.19/centos7
baseurl=file:///home/iso
#启动yum源: 1-启用 0-不启用
enabled=1 
#安全检测:  1-开启 0-不开启
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


yum clean all

yum makecache


---单独只使用这个本地源:

yum  --disablerepo="*" --enablerepo=c7-media

---disablerepo="*"  也可以不用输

yum  --enablerepo=c7-media install zsh 


-安装并启动httpd服务

yum -y install httpd

systemctl start httpd.service #启动apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重启apache

systemctl enable httpd.service #设置开机启动

ln -s /home/iso /var/www/html/centos7


---移除httpd软件

yum -y remove httpd


vi /etc/yum.repos.d/CentOS-local.repo

#本源的名字(不能和其他重复)
[base-local]
name=CentOS7-local
#这里的IP根据现场的yum源决定
baseurl=http://44.135.8.19/centos7
#baseurl=file:///home/iso
#启动yum源: 1-启用 0-不启用
enabled=1 
#安全检测:  1-开启 0-不开启
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

局域网内其他机器也一样,修改一下baseurl即可


---卸载镜像:

umount  /home/iso


签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回