Common CentOS Yum Repository Configurations

Configuring a Local Yum Repository

Mount and Use an ISO Image Directly

  1. Backup the original yum repository configuration file
1
cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. Mount the ISO image
1
mount -t iso9660 -o loop /home/OracleLinux-R6-U5-Server-x86_64-dvd.iso /mnt
  1. Edit the configuration file
1
vi /etc/yum.repos.d/local.repo

The content of the configuration file is as follows:

1
2
3
4
5
[local_server]
name=local_repo
baseurl=file:///mnt
enabled=1
gpgcheck=0
  1. Clear Yum Cache and Generate a New Cache
1
yum clean all && yum makecache

Configuring a Yum Repository for China

  1. Backup the original yum repository configuration file
1
cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. Download the Alibaba Cloud Yum repository configuration file
1
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  1. Clear Yum cache and generate a new cache
1
yum clean all && yum makecache