Local installation of .rpms using YUM

173,340

Solution 1

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

Solution 2

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.

Share:
173,340

Related videos on Youtube

waldemar_enns
Author by

waldemar_enns

Primarily Informix-4GL Programmer, Linux Bash Programmer and Linux Administrator. Dabbler in Java, Python, HTML, PHP and JavaScript. Expert at breaking everything.

Updated on September 18, 2022

Comments

  • waldemar_enns
    waldemar_enns almost 2 years

    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?

  • waldemar_enns
    waldemar_enns over 9 years
    this worked great, I don't suppose there is a YUM equivalent?
  • Atul Vekariya
    Atul Vekariya over 9 years
    To clarify: yum is wrapper around rpm. rpm is the main program to manage packaged in RHEL, SuSE, CentOS and other distributions
  • waldemar_enns
    waldemar_enns over 9 years
    Oh I always thought yum was based on rpm, never realized it was a wrapper, thanks for all your help
  • waldemar_enns
    waldemar_enns about 8 years
    I do like doing things according to best practices and this answer includes the yum equivalent that I was hoping for. Unfortunately I've installed a whole bunch of packages using the rpm -ivh method already. I wish it were possible to accept two correct answers because I feel the accepted answer is correct but people coming to view this question would benefit more from this answer
  • Alexej Magura
    Alexej Magura over 6 years
    Do you have to be root to run this command?
  • Atul Vekariya
    Atul Vekariya over 6 years
    Correct, you must be root to run the command
  • elbarna
    elbarna over 5 years
    Is better to use yum instead of rpm,but to solve the "warning: RPMDB altered outside of yum" is possible to use "yum history sync"
  • Christian Shay
    Christian Shay over 5 years
    This works. When I tried just running rpm it didn't go get the dependencies. It just errored with "Failed dependencies".
  • hmz
    hmz over 5 years
    "yum --nogpgcheck localinstall packagename.arch.rpm"