mirrors-for-coder
這裏作一個集中,儘管之前都是遇到時當即搜索,可是集中一下以後,看起來也很壯觀的。php
固然,歡迎完善它。前端
經過HTTPS協議Clone倉庫的話,可能會遇到速度很慢的狀況。node
根據經驗,在慢的時候中斷Clone捎帶片刻重複命令的話,你可能會獲得正常速度,這種偷雞的策略適合於小小倉庫。linux
對於大型倉庫,改走SSH協議進行clone的話,走到正常速度的概率較大,但此時的速度相較於HTTPS而言一般會有所損耗。laravel
但下面還有一種較爲費事的方法,經過修改 hosts 文件來完成提速,無需科學也無需代理加速也無需鏡像加速(GitHub是不太可能有鏡像的)。具體來講請接下去閱讀:git
首先在 https://www.ipaddress.com/ 查詢這三個域名的地址:github
而後按照查詢的結果填寫到 /etc/hosts 中,windows用戶請查找 %WINDIR%/system32/drivers/etc/hosts 文件。請注意修改 hosts 文件一般須要 sudo 權限 或者管理員權限。修改內容如同下面:spring
140.82.118.3 github.com 185.199.109.153 assets-cdn.github.com 185.199.111.153 assets-cdn.github.com 185.199.108.153 assets-cdn.github.com 185.199.110.153 assets-cdn.github.com 151.101.113.194 github.global.ssl.fastly.net
若是你有國外的服務器,也能夠經過dig指令來查找:docker
$ dig github.com +short 140.82.118.3
Docker CE 的具體加速辦法有不少種,然而各類版本的本質都是同樣的,通常來講你須要找到 docker daemon 的配置文件 /etc/docker/daemon.json
,而後修改它像這樣:apache
{ "insecure-registries" : [ "registry.mirrors.aliyuncs.com" ], "debug" : true, "experimental" : false, "registry-mirrors" : [ "https://docker.mirrors.ustc.edu.cn", "https://dockerhub.azk8s.cn", "https://reg-mirror.qiniu.com", "https://registry.docker-cn.com" ] }
若是你在這個文件中自定義了其餘項目,或者這個文件中已經存在其餘定義,請注意保持。
參考:https://docs.docker.com/engin...
若是你使用桌面版本,則 Ubuntu 的軟件源設置中,你能夠選取最近的地區,例如中國大陸,從而加速軟件包下載速度。
若是使用 Server 版本,則能夠明確地使用清華鏡像(或者自行使用其餘鏡像)
# 默認註釋了源碼鏡像以提升 apt update 速度,若有須要可自行取消註釋 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # 預發佈軟件源,不建議啓用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
以上例子爲 18.04 版本的替換內容。你能夠直接訪問清華開源站查找其餘版本:
https://mirror.tuna.tsinghua....
https://askubuntu.com/questio...
能夠用pip安裝它:
pip install apt-select
而後運行它並跟隨提示走:
apt-select --country US -t 5 --choose
apt-get now supports a 'mirror' method that will automatically select a good mirror based on your location. Putting:
deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse deb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse
on the top in your /etc/apt/sources.list
file should be all that is needed to make it automatically pick a mirror for you based on your geographical location.
你能夠無腦地使用 sed 來搞定:
sudo sed -i 's%us.archive.ubuntu.com/ubuntu/%mirrors.ubuntu.com/mirrors.txt%' /etc/apt/sources.list
清華提供一種Apk源加速方式:https://mirror.tuna.tsinghua....
在終端輸入如下命令以替換TUNA鏡像源: sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
製做 Docker 鏡像時,這是頗有用的,節約生命真的是美德。
清華提供一種 Arch Linux 軟件倉庫加速方式:https://mirror.tuna.tsinghua....
編輯 /etc/pacman.d/mirrorlist, 在文件的最頂端添加: Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
更新軟件包緩存: sudo pacman -Syy
使用 Golang v1.11 以上,爲你的項目啓用 Go Modules 功能,而後就可使用 GOPROXY 環境變量來透明地使用鏡像代理。
比較著名的大陸加速器爲:
export GOPROXY=https://goproxy.cn # Windows 應該使用 set GOPROXY=xxxx 語法
而後 go mod download
以及 go mod tidy
就足夠快了。
若是你想搭建私服,能夠遵循 Go Modules 的 API 規範本身實現一個代理服務器,也可使用開源的 athens 項目自建一個服務器。
若是使用 Golang 1.13 以上版本的話,一下語法可用:
export GOPROXY=direct,https://goproxy.cn,https://goproxy.io,https://gocenter.i o
國內有多家組織提供 Android SDK的鏡像緩存,甚至我的也能夠很容易地創建這樣的緩存,若是你有國內訪問速度很好的國外服務器的話。
可是,隨着時間推移,如今這些鏡像基本上都已失效了。
取而代之的是,目前,Android的官方源是能夠直連的,且能達到正常速度,因此仍是趕忙滴作點負責任的app出來吧,不要只是會矽肺或者偷偷上傳神馬的。
Gradle的配置文件爲~/.gradle/init.gradle
:
allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/public/' } } buildscript { repositories { maven { url 'https://maven.aliyun.com/repository/public/' } } } }
如下的鏡像能夠選用
首先是 gem 和 ruby 的源應該被替換
$ gem sources --remove https://rubygems.org
$ gem sources -a https://gems.ruby-china.com
$ gem sources -l
幾種加速方法,可能須要本身實際測試那種效果最好。
pod repo remove master pod repo add master https://gitee.com/mirrors/CocoaPods-Specs pod repo update
pod repo remove master pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git pod repo update
對於 Cocoapods 新的版本,須要使用以下的方法:
pod repo remove master cd ~/.cocoapods/repos git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
source 'https://gitee.com/mirrors/CocoaPods-Specs.git' source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
macOS 中都會安裝 Homebrew,但 brew update
可能會很慢。加速的辦法是替換現有的上游:
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git brew update
(感謝Snowonion Lee提供說明)
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git brew update
以上內容從清華開源上覆制:Homebrew 鏡像使用幫助
若是想阻止 brew 指令運行時老是嘗試去自動更新,能夠設置環境變量:
# forbit autoupdate on homebrew installing export HOMEBREW_NO_AUTO_UPDATE=1
flutter 官網有專門的頁面講述加速問題:
https://flutter.dev/community...
Flutter 是一款跨平臺的移動應用開發框架,由 Google 開源。用 Flutter 開發的應用能夠直接編譯成 ARM 代碼運行在 Android 和 iOS 系統上。
可使用清華鏡像:https://mirror.tuna.tsinghua....
Flutter 安裝時須要從 Google Storage 下載文件,如您的網絡訪問 Google 受阻,建議使用本鏡像。使用方法爲設置環境變量 FLUTTER_STORAGE_BASE_URL
,並指向 TUNA 鏡像站。
$ export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"
若但願長期使用 TUNA 鏡像:
$ echo 'export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"' >> ~/.bashrc
此外 Flutter 開發中還須要用到 Dart 語言的包管理器 Pub,其鏡像使用方法參見Pub 鏡像安裝幫助。
Pub 是 Dart 官方的包管理器。跨平臺的前端應開發 框架 Flutter 也基於 Dart 而且可使用大部分 Pub 中的 庫。
若是但願經過 TUNA 的 pub 鏡像安裝軟件,只須要設置 PUB_HOSTED_URL 這個環境變量指向 https://mirrors.tuna.tsinghua... 便可。
以 bash 爲例,臨時使用 TUNA 的鏡像來安裝依賴:
$ PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" pub get # pub $ PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" flutter packages get # flutter
若但願長期使用 TUNA 鏡像:
$ echo 'export PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"' >> ~/.bashrc
Rust 使用 creates.io,國內也有相應的提速手段:
https://lug.ustc.edu.cn/wiki/...
首先你須要在 $HOME/.cargo/config 中添加以下內容
[registry] index = "git://mirrors.ustc.edu.cn/crates.io-index" # Or # index = "http://mirrors.ustc.edu.cn/crates.io-index"
若是 cargo 版本爲 0.13.0 或以上, 須要更改 $HOME/.cargo/config 爲如下內容:
[source.crates-io] registry = "https://github.com/rust-lang/crates.io-index" replace-with = 'ustc' [source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index"
有興趣自建的朋友,能夠看看:
https://github.com/rust-lang/...
清華TUNA 也有 rustup 相應的鏡像
# export CARGO_HOME=$HOME/.cargo # export RUSTUP_HOME=$HOME/.rustup export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
詳見:https://mirror.tuna.tsinghua....
編輯 $HOME/.m2/settings.xml
,找到 <mirrors>
小節,添加以下內容:
<mirror> <id>aliyun-public</id> <mirrorOf>*</mirrorOf> <name>aliyun public</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> <mirror> <id>aliyun-central</id> <mirrorOf>*</mirrorOf> <name>aliyun central</name> <url>https://maven.aliyun.com/repository/central</url> </mirror> <mirror> <id>aliyun-spring</id> <mirrorOf>*</mirrorOf> <name>aliyun spring</name> <url>https://maven.aliyun.com/repository/spring</url> </mirror> <mirror> <id>aliyun-spring-plugin</id> <mirrorOf>*</mirrorOf> <name>aliyun spring-plugin</name> <url>https://maven.aliyun.com/repository/spring-plugin</url> </mirror> <mirror> <id>aliyun-apache-snapshots</id> <mirrorOf>*</mirrorOf> <name>aliyun apache-snapshots</name> <url>https://maven.aliyun.com/repository/apache-snapshots</url> </mirror> <mirror> <id>aliyun-google</id> <mirrorOf>*</mirrorOf> <name>aliyun google</name> <url>https://maven.aliyun.com/repository/google</url> </mirror> <mirror> <id>aliyun-gradle-plugin</id> <mirrorOf>*</mirrorOf> <name>aliyun gradle-plugin</name> <url>https://maven.aliyun.com/repository/gradle-plugin</url> </mirror> <mirror> <id>aliyun-jcenter</id> <mirrorOf>*</mirrorOf> <name>aliyun jcenter</name> <url>https://maven.aliyun.com/repository/jcenter</url> </mirror> <mirror> <id>aliyun-releases</id> <mirrorOf>*</mirrorOf> <name>aliyun releases</name> <url>https://maven.aliyun.com/repository/releases</url> </mirror> <mirror> <id>aliyun-snapshots</id> <mirrorOf>*</mirrorOf> <name>aliyun snapshots</name> <url>https://maven.aliyun.com/repository/snapshots</url> </mirror> <mirror> <id>aliyun-grails-core</id> <mirrorOf>*</mirrorOf> <name>aliyun grails-core</name> <url>https://maven.aliyun.com/repository/grails-core</url> </mirror> <mirror> <id>aliyun-mapr-public</id> <mirrorOf>*</mirrorOf> <name>aliyun mapr-public</name> <url>https://maven.aliyun.com/repository/mapr-public</url> </mirror>
也能夠採用 profile 方式,這裏就再也不贅述了。
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set global.index-url https://mirrors.huaweicloud.com/repository/pypi/simple
pip config set global.index-url https://pypi.douban.com/simple
# 如下能夠選用其一 # 清華: pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple # 阿里: pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ # 華爲: pip config set global.index-url https://mirrors.huaweicloud.com/repository/pypi/simple # 豆瓣: pip config set global.index-url https://pypi.douban.com/simple
# 如下能夠選用其一 # 阿里: composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 華爲: composer config -g repo.packagist composer https://mirrors.huaweicloud.com/repository/php/ # Laravel中文網 composer config -g repo.packagist composer https://packagist.laravel-china.org
能夠更換鏡像:
yarn config set registry https://registry.npm.taobao.org
yarn config set registry https://mirrors.huaweicloud.com/repository/npm/
npm config set sass_binary_site https://mirrors.huaweicloud.com/node-sass/
沒有簡單的辦法。一些周知的鏡像,能夠經過這些地方加速:
對於 Ubuntu 之類,能夠取清華鏡像
vagrant box add ubuntu/trusty64 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box vagrant box add ubuntu/bionic64 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/bionic/20191002/bionic-server-cloudimg-amd64-vagrant.box
清華找不到幾個周知鏡像,因此基本上仍是要在 http://www.vagrantbox.es/ 尋找和添加
vagrant box add debian/8.1 https://github.com/kraksoft/vagrant-box-debian/releases/download/8.1.0/debian-8.1.0-amd64.box
CC4