Linux修改系統以及pip更新源__Linux

來源:互聯網
上載者:User
修改系統更新源

你是否跟我一樣在剛看時接觸Linux時被系統更新源問題搞得暈頭轉向,不同的Linux更新源配置也是不一樣的,另外由於預設安裝時的源大都是外國的更新源,速度相對國內會慢很多,接下來主要介紹在centos和ubuntu系統中更新系統源的方法,更新源以163的更新源為例 centos更新系統源

首先備份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

下載對應版本repo檔案, 放入/etc/yum.repos.d/(再次提醒操作前請做好相應備份)
CentOS7
CentOS6
CentOS5
最後運行一下命令產生緩衝

yum clean allyum makecache

盡情享受飛一般的速度吧 ubuntu更新系統源

首先備份/etc/apt/sources.list

mv /etc/apt/sources.list /etc/apt/sources.list.bak

然後下載相應版本的sources.list, 覆蓋/etc/apt/sources.list即可(再次提醒操作前請做好相應備份)
lucid(10.04)
precise(12.04)
trusty(14.04)
utopic(14.10)
vivid(15.04)
wily(15.10)
覆蓋完成之後即可使用,如果不做備份也可以直接修改/etc/apt/sources.list檔案,以Wily(15.10)為例, 編輯/etc/apt/sources.list檔案, 在檔案最前面添加以下條目(再次操作前請做好相應備份)

deb http://mirrors.163.com/ubuntu/ wily main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ wily main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse

修改完成儲存
最後需要執行

sudo apt-get update
修改pip更新源

pip安裝時預設訪問pypi的,但是pypi的速度對於國內來說有點慢,還在國內也有一些pip的鏡像源,造福廣大程式員
pipy國內鏡像目前有:
http://pypi.douban.com/ 豆瓣
http://pypi.hustunique.com/ 華中理工大學
http://pypi.sdutlinux.org/ 山東理工大學
http://pypi.mirrors.ustc.edu.cn/ 中國科學技術大學
安裝時我們可以手動指定安裝源如下:

pip -i http://pypi.douban.com/simple install Flask

如果感覺每次安裝都手動指定安裝源麻煩的話,也可以配置pip更新源
在主目錄下建立.pip檔案夾

mkdir ~/.pip

然後在該目錄下建立pip.conf檔案編寫如下內容:

[global]trusted-host =  pypi.douban.comindex-url = http://pypi.douban.com/simple

這裡以豆瓣的源為例,由於最新的pip安裝需要使用的https加密,所以在此需要添加trusted-host
對於window系統來說基本配置相同建立或修改設定檔在%HOMEPATH%\pip\pip.ini 參考連結:

http://topmanopensource.iteye.com/blog/2004853
http://mirrors.163.com/.help/ubuntu.html
http://mirrors.163.com/.help/centos.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.