Build a local YUM repository in Centos 7
Use CentOS7.iso to build a local repository
(1) copy the CentOS7.iso file to your main directory :~
cp CentOS7.iso ~
(2) create a directory where the iso file will be mounted
mkdir -p /mnt/cdrom
(3) mount the iso file to the directory just created
mount -o loop CentOS7.iso /mnt/cdrom
(4) Create the repo File Local. repo and add the following content to it:
Vim/etc/yum. repos. d/Local. repo
[Local] name = Local Yum baseurl = file: // mnt/cdrom gpgcheck = 1 gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled = 1
PS: In this method, you do not need to use createrepo to create an index file, because the index file already created in the ISO file is located in the repodata folder.
Create a custom local YUM Source
This method is mainly applicable to the fact that we have already added some RPM packages to our favorites. We want to make the collected RPM packages into our own YUM repository, which facilitates offline installation and is flexible and convenient. (1) create a directory for the local repository, for example, root.
Mkdir/root/local
(2) Move all the RPM packages to this directory.
Mv *. rpm/root/local
(3) install createrepo
Yum-y install createrepo
(3) create an index using createrepo
Createrepo/root/local
(4) create a repo File
Vim/etc/yum. repos. d/Local. repo:
[Local] name = Local Yum baseurl = file: // root/local gpgcheck = 1 gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled = 1
At this point, the above two methods have been successfully created to create a local repository. You only need to update the cache below.
Yum makecache