當安裝軟件時,終端會顯示connecting to us.archive.ubuntu.com,這說明操做系統給在嘗試與某個網站進行鏈接,但顯然該網站是國外網站,所以會下降軟件的安裝速度。爲了提高速度,咱們選擇提早更換代理,即將其換成阿里雲或騰訊雲的鏡像源。
但若是使用的是阿里雲服務器或騰訊雲服務器,則並不須要進行更換。
方法一
直接修改/etc/apt/sources.list文件:linux
$sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak //備份源文件 $sudo vim /etc/apt/sources.list //更改源文件
將源文件內容更換爲某個鏡像源(此處爲阿里鏡像源):apache
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
方法二
若ubuntu不能執行復制粘貼,則能夠先將鏡像源寫入某個文件,而後將其傳到雲服務器上,後經過wget命令(經過http來請求一個資源),獲取該文件資源,而後在ubuntu中將源文件置換爲新下載的文件。ubuntu
$wget http:// $mv sources.list.now /etc/apt/ $rm sources.list $mv sources.list.now sources.list
在linux操做系統中存在一個清單文件/etc/apt/sources.list,清單中存放着相關軟件的地址,例如apache2的安裝地址,當執行安裝命令時,linux系統會根據清單中提供的地址去訪問並獲取資源,進行軟件安裝。
但容易出現的問題是,清單中的源地址與軟件當前的下載地址已不匹配。所以在安裝軟件以前須要執行更新源命令:vim
#apt-get update
#apt-get install apache2
apt爲ubuntu安裝軟件時使用的命令。
在安裝軟件的過程當中若對軟件名稱不肯定,能夠雙擊tab鍵,查看提示。服務器