How to change the yum repository to a local source in C…
To change the yum repository of CentOS 7 to a local repository, you can follow these steps:
- First, open the terminal window of the CentOS 7 system.
- Log in to the system with root access.
- Back up the original yum repository configuration file.
- Create a backup copy of the CentOS-Base.repo file in the /etc/yum.repos.d/ directory.
- Open the yum repository configuration file using a text editor such as vi or nano.
- Open the file CentOS-Base.repo located in the directory /etc/yum.repos.d using the vi editor.
- Comment out the original yum repository configuration and add a local repository configuration.
- [base]
name=CentOS-$releasever – Base
baseurl=file:///path/to/local/repo
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[updates]
name=CentOS-$releasever – Updates
baseurl=file:///path/to/local/repo
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[extras]
name=CentOS-$releasever – Extras
baseurl=file:///path/to/local/repo
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[centosplus]
name=CentOS-$releasever – Plus
baseurl=file:///path/to/local/repo
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[contrib]
name=CentOS-$releasever – Contrib
baseurl=file:///path/to/local/repo
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 - In the aforementioned configuration, replace /path/to/local/repo with the path to your local source.
- Save and close the file.
- Clear the yum cache.
- clear all package cache
- Regenerate the yum cache.
- refresh the yum cache
You have now successfully switched the yum source of CentOS 7 to a local source. You can use the yum command to install and update packages.