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 file, as well as from a URL of a remotely available package.
In this article, I will describe how to 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.
However if you are behind a proxy, the above command will produce the following error.
Retrieving http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm curl: (7) couldn't connect to host error: skipping http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm - transfer failed
There are two ways to configure your proxy with the rpm command.
The first method is to use rpm's command-line options. That is, run the rpm command in the following format to specify your proxy.
For example, if your proxy is located at "my.proxy.com:8000":
The second method to install .RPM packages through a proxy is to use an environment variable named http_proxy. If you want, you can set the environment variable system-wide.
As long as the http_proxy environment variable is pointing to your proxy (e.g., my.proxy.com:8000), you don't have to specify the proxy via command-line options 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 environment variable is preserved in sudo sessions. To do so, append "http_proxy" to "env_keep" variable in the sudo configuration file, as follows.
Defaults env_reset . . . . Defaults env_keep += "http_proxy"
With the above configuration, the http_proxy environment variable 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 a proxy.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to install Suricata intrusion detection system on Linux - September 3, 2015
- How to switch from NetworkManager to systemd-networkd on Linux - August 31, 2015
- How to set up a system status page of your infrastructure - August 25, 2015