Last updated on July 20, 2013 by Dan Nanni
RPM (RPM Package Manager) is a command-line utility for installing, removing, querying and updating .RPM packages for RedHat-based systems such as CentOS, RHEL or Fedora. Using rpm
command, you can install a package from a locally downloaded .RPM package file or from a URL of a remotely available package.
This article describes how you can install .RPM package from a URL when you are behind a proxy.
In typical scenarios where you are not behind a proxy, you can install from a URL with rpm
as follows.
$ sudo rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
If you are behind a proxy, there are two ways to configure the proxy for rpm
command.
The first method is to use command line options for rpm
command. To install a .RPM package behind a proxy, run rpm
command in the following format.
$ sudo rpm -ivh --httpproxy [proxy server's IP address or host name] --httpport [proxy port number] [URL of a RPM file]
For example, if your proxy is located at my.proxy.com:8000
:
$ sudo rpm -ivh --httpproxy my.proxy.com --httpport 8000 http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
The second method to install .RPM packages through a proxy is to use environment variables called http_proxy
and https_proxy
. If you want, you can set those environment variables system-wide.
As long as the http_proxy
and https_proxy
environment variables are pointing to your proxy (e.g., my.proxy.com:8000
), you don't have to specify the proxy via command-line options for yum
command like the first method.
One caveat of this approach is that any environment variable that you define could be reset and lost with sudo
. Therefore, you need to make sure that the http_proxy
and https_proxy
environment variables are preserved in sudo
sessions. To do so, append http_proxy
and https_proxy
to env_keep
variable in the sudo
configuration file, as follows.
$ sudo visudo
Defaults env_reset. . . . Defaults env_keep += "http_proxy" Defaults env_keep += "https_proxy"
With the above configuration, the http_proxy
and https_proxy
environment variables will be kept while you are running sudo
commands. Now, you can install .RPM packages from their URL sources as follows, even when you are behind behind a proxy.
$ sudo rpm -ivh --httpproxy my.proxy.com --httpport 8000 http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
This website is made possible by minimal ads and your gracious donation via PayPal (Credit Card) or Bitcoin (BTC Wallet: 1M161JGAkz3oaHNvTiPFjNYkeABox8rb4g
).
Xmodulo © 2020 ‒ About ‒ Powered by DigitalOcean