Local installation of .rpms using YUM

I’m asking this question cautiously because I don’t want to get this wrong.

I have a program_name.rpm file saved locally on my server (CentOS 6.5).

I have installed it previously just by navigating to it and using yum install program_name.rpm which worked fine but it didn’t give me any option to specify where it is installed.

Is it possible to install this rpm to /opt/some_directory instead of it’s default install location?

Asked By: TheLovelySausage


Use rpm

rpm -ivh package.rpm

If you want to install it on different place use:

rpm -ivh -r /new/path package.rpm

but be aware under new root will be recreated the directory structure from package

Answered By: Romeo Ninov

Too bad you accepted that rpm answer. That will lead to warnings from subsequent executions of yum, such as
Warning: RPMDB altered outside of yum

Instead you should use yum localinstall, per section 13 of the Yum and RPM Tricks page of the CentOS wiki => https://wiki.centos.org/TipsAndTricks/YumAndRPM#head-3c061f4a180e5bc90b7f599c4e0aebdb2d5fc7f6

You can use the --installroot option to specify a different installation root.

Answered By: Jeff