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版本的話,須要運行。

相關文章
相關標籤/搜索