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
Option #1
I like to use yum-downloadonly to download packages locally.
yum install yum-plugin-downloadonly
Make a directory where you will download the RPMs.
mkdir /nfs
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
ls /nfs
git-1.7.1-4.el6_7.1.x86_64.rpm
If you think that you have already installed the files, you should use reinstall:
yum reinstall git -y --downloadonly --downloaddir=/nfs
Option #2
A second option is to use yumdownloader. I prefer Option #1 though.
yum install yum-utils
yumdownloader git
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.
cd /nfs
Install all the RPM packages locally:
yum --nogpgcheck localinstall *.rpm