博客作者:联系请
点击 ,搬运不易,希望请作者喝咖啡,可以点击
联系博客作者 Operation OS
deepin 配置阿里源
sudo vim /etc/apt/sources.list
复制 #阿里稳定源:
deb [by-hash=force] http://mirrors.aliyun.com/deepin lion main contrib non-free
#阿里不稳定源:
deb [by-hash=force] http://mirrors.aliyun.com/deepin panda main contrib non-free
Ubuntu
apt 配置代理
sudo apt-get -o Acquire::http::proxy="socks5h://127.0.0.1:1080/" update
NPM
npm 配置官方源
npm config set registry http://registry.npmjs.org/
npm 配置淘宝源
npm set registry https://registry.npm.taobao.org
npm 配置腾讯源
npm config set registry http://mirrors.cloud.tencent.com/npm/
yarn 配置源
yarn config set registry https://registry.npm.taobao.org
yarn config set registry http://mirrors.cloud.tencent.com/npm/
PiP
pip 配置清华源
pypi 镜像每 5 分钟同步一次。
临时使用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
注意,simple 不能少, 是 https 而不是 http
设为默认
升级 pip 到最新的版本 (>=10.0.0) 后进行配置:
pip3 install pip -U
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
Github
复制 Github国内加速克隆及下载 fastgit.org
https://doc.fastgit.org/
gitclone.com
https://gitclone.com/
gitee
https://gitee.com/mirrors
cnpmjs.org
https://github.com.cnpmjs.org/
克隆加速
复制 #原地址 git clone
https://github.com/kubernetes/kubernetes.git
#改为 git clone
https://github.com.cnpmjs.org/kubernetes/kubernetes.git
#或者 git clone
https://hub.fastgit.org/kubernetes/kubernetes.git
#或者 git clone
https://gitclone.com/github.com/kubernetes/kubernetes.git
release下载加速
复制 #原地址 wget
https://github.com/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz
#改为 wget
https://hub.fastgit.org/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz
#免替换方法
git config --global url."https://hub.fastgit.org".insteadOf
https://github.com
#测试 git clone
https://github.com/kubernetes/kubernetes.git
查看git配置信息
git config --global --list
取消设置
git config --global --unset url.https://github.com/.insteadof
raw文件下载加速
复制 #原地址: wget
https://raw.githubusercontent.com/kubernetes/kubernetes/master/README.md
#替换为 wget
https://raw.staticdn.net/kubernetes/kubernetes/master/README.md
提供web界面的github资源加速网站:
复制 GitHub 文件加速:https://gh.api.99988866.xyz/
Github 仓库加速:https://github.zhlh6.cn/
Github 仓库加速:http://toolwa.com/github/
Go
说明
众所周知,国内网络访问国外资源经常会出现不稳定的情况,Go 生态系统中有着许多中国 Gopher 们无法获取的模块,比如最著名的 golang.org/x/...。并且在中国大陆从 GitHub 获取模块的速度也有点慢。
因此设置 CDN 加速代理就很有必要了,以下是几个速度不错的提供者:
阿里: mirrors.aliyun.com/goproxy/
Unix 类
在 Linux 或 macOS 上面,需要运行下面命令(或者,可以把以下命令写到 .bashrc
或 .bash_profile
文件中):
复制 # 启用 Go Modules 功能
go env -w GO111MODULE=on
# 配置 GOPROXY 环境变量,以下三选一
# 1. 七牛 CDN
go env -w GOPROXY=https://goproxy.cn,direct
# 2. 阿里云
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
# 3. 官方
go env -w GOPROXY=https://goproxy.io,direct
确认一下:
复制 go env | grep GOPROXY
GOPROXY="https://goproxy.cn"
Windows 类
在 Windows 上,需要运行下面命令:
复制 # 启用 Go Modules 功能
$env:GO111MODULE="on"
# 配置 GOPROXY 环境变量,以下三选一
# 1. 七牛 CDN
$env:GOPROXY="https://goproxy.cn,direct"
# 2. 阿里云
$env:GOPROXY="https://mirrors.aliyun.com/goproxy/,direct"
# 3. 官方
$env:GOPROXY="https://goproxy.io,direct"
私有模块
如果你使用的 Go 版本 >=1.13, 你可以通过设置 GOPRIVATE 环境变量来控制哪些私有仓库和依赖 (公司内部仓库) 不通过 proxy 来拉取,直接走本地,设置如下:
复制 # Go version >= 1.13
go env -w GOPROXY=https://goproxy.cn,direct
# 设置不走 proxy 的私有仓库,多个用逗号相隔
go env -w GOPRIVATE=*.corp.example.com
Docker
1. 安装/升级Docker客户端
推荐安装1.10.0以上版本的Docker客户端,参考文档 docker-ce
2. 配置镜像加速器
针对Docker客户端版本大于 1.10.0 的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json
来使用加速器
复制 sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://u13zwy2w.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker