ubunto apt config proxy 配置代理或者运行在代理网络的环境下

问题描述:
php


若是你是在主机 代理网络的环境下,而且客户端你有建立了虚拟机的Linux ,你会发现不少时候并不能在虚拟机下载更新软件。
java

好比:unbutu 下面apt-get update不少时候都是失败的。ubuntu


解决方法:

对于ubuntu 能够采用以下方法。ruby

一、在/etc/apt/文件夹下面新创建 apt.conf 文件网络

而后添加ide

ubuntu@ubuntu:~$ cat /etc/apt/apt.conf
Acquire::http::Proxy "http://Username:Password@proxy.xxx.xxx.xxx.xxx:8080";

说明:若是代理没有密码,能够不用写,直接以下。

Acquire::http::Proxy "http://proxy.xxx.xxx.xxx.xxx:8080";

二、配置环境变量 ui

在  /etc/environment 中添加this

export http_proxy=http://username:password@host:port/
export https_proxy=https://username:password@host:port/

三、而后运行sudo    spa

sudo add-apt-repository XXX  ##若是有代理的状况下加不上能够 在不适用代理的网络里面加 好比guest网络

 -E, --preserve-env代理

 Indicates to the security policy that the user wishes to preserve their existing environment variables.  The security

policy may return an error if the user does not have permission to preserve the environment.

add-apt-repository adds a PPA to your list of sources, so that Ubuntu knows to look for updates from that PPA as well as from the official Ubuntu sources. Usually this is used to allow developers to provide updates more quickly than those in the official Ubuntu repositories.

apt-get update tells apt-get to update its database of what packages can be installed and where to install them from. In this case, apt-get will see your newly-added PPA and discover that ppa:maco.m/ruby has the newest version of rubygems that it knows about, so it will make a note to install rubygems from the PPA next time someone asks to install it.

apt-get install causes apt-get to find the package in its database and download and install the indicated file. In this case, it will find the rubygems package, download it from ppa:maco.m/ruby, and install it.

实  例:

更新 ubutu 的openjdk8 步骤以下:

能够参考http://ubuntuhandbook.org/index.php/2015/01/install-openjdk-8-ubuntu-14-04-12-04-lts/

  1. sudo add-apt-repository ppa:openjdk-r/ppa ##若是有代理的状况下加不上能够 在不适用代理的网络里面加 好比guest网络 下面 先加上这个

  2. sudo apt-get update

  3. sudo apt-get install openjdk-8-jdk

  4. sudo update-alternatives --config java

   ## 若是你安装好了,对于你的系统中有多个jdk版本的话,须要运行。

        ##  enter the number for which JDK to use of your choice.

 5. sudo update-alternatives --config javac

        ## 若是你安装好了,对于你的系统中有多个jdk版本的话,须要运行。

相关文章
相关标签/搜索