当前位置:主页 > 服务器 > Linux >

详解centos7配置本地yum源的方法

时间:2021-06-11 08:10:11 | 栏目:Linux | 点击:

最近在使用虚拟机时遇到一些麻烦,因为公司内部有网络管理,所以vm连接不上外网,yum无法安装软件,怎么解决呢??C使用iso做本地yum源,可以解决大部份的包安装。

vm安装的是centos7。

1、挂载iso到vm

#mkdir /mnt/cdrom
#mount /dev/cdrom /mnt/cdrom

2、修改yum源配置

yum源配置目录为“/etc/yum.repo.d/”,网络不可用,所以直接删除掉里面的默认配置“rm -f *”,然后建立本地yum源文件”local.repo”。

yum源配置文件都是以repo结尾,以下是local.repo的具体内容:

[local_server]
name=This is a local repo
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

3、更新yum配置

#yum clean all
#yum makecache

通过上面的步骤操作,已经可以使用本地yum源了。有需要进行安装的软件包就可以直接运行”yum install xxx“进行安装了。

您可能感兴趣的文章:

相关文章