On CentOS, we sometimes need to install yum packages as RPMs locally because we may need them at a time when we don’t have internet access.
How to Download Yum Packages Locally
I like to use yum-downloadonly to download packages locally.
yum install yum-plugin-downloadonly
Make a directory where you will download the RPMs.
Now, we use –downloadonly to download all the RPMs of the package and its dependencies into the /nfs directory.
yum install git -y --downloadonly --downloaddir=/nfs
If you think that you have already installed the files, you should use reinstall:
yum reinstall git -y --downloadonly --downloaddir=/nfs
A second option is to use yumdownloader. I prefer Option #1 though.
yum install yum-utils
How to Install Yum Downloaded Packages Locally
Change directory to where all the .rpm’s are stored. Yum downloader downloads the packages and dependencies as .rpm’s.
Install all the RPM packages locally:
yum --nogpgcheck localinstall *.rpm