Build a local YUM repository in Centos 7

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.