In this tutorial, How to install an RPM package into a different directory on Centos.
For example, Install package bind install into another directory /opt/bind.
Using rpm -qi command to check the package have been installed not yet
$ sudo rpm -qi [name-package]
Not all RPM packages can be installed into another directory.
For example, the bind RPM package is not relocatable. You install it then error: package bind is not relocatable
[vagrant@DevopsRoles ~]$ rpm -qpi bind-9.8.2-0.68.rc1.el6_10.1.x86_64.rpm | head -1
Name : bind Relocations: (not relocatable)
Install an RPM package into a different directory.
For example, wkhtmltox RPM package as below
[vagrant@DevopsRoles ~]$ wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos6.x86_64.rpm
[vagrant@DevopsRoles ~]$ rpm -qpi wkhtmltox-0.12.5-1.centos6.x86_64.rpm | head -1
Name : wkhtmltox Relocations: /usr/local
[vagrant@DevopsRoles ~]$ sudo rpm -ivh --prefix=/opt/wkhtmltox wkhtmltox-0.12.5-1.centos6.x86_64.rpm
Check the result installed wkhtmltox on your system.
[vagrant@DevopsRoles ~]$ tree /opt/wkhtmltox
/opt/wkhtmltox
├── bin
│ ├── wkhtmltoimage
│ └── wkhtmltopdf
├── include
│ └── wkhtmltox
│ ├── dllbegin.inc
│ ├── dllend.inc
│ ├── image.h
│ └── pdf.h
├── lib
│ ├── libwkhtmltox.so -> libwkhtmltox.so.0.12.5
│ ├── libwkhtmltox.so.0 -> libwkhtmltox.so.0.12.5
│ ├── libwkhtmltox.so.0.12 -> libwkhtmltox.so.0.12.5
│ └── libwkhtmltox.so.0.12.5
└── share
└── man
└── man1
├── wkhtmltoimage.1.gz
└── wkhtmltopdf.1.gz
7 directories, 12 files
Conclusion
Thought the article, How to use “Install an RPM package into a different directory” as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!