国内镜像源配置

各种镜像源配置, deepin, ubuntu, pip, npm, yarn...

  • 约 23 分钟
  • 6,630 字

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

Ubuntu,是一款基于Debian Linux的以桌面应用为主的操作系统,内容涵盖文字处理、电子邮件、软件开发工具和Web服务等,可供用户免费下载、使用和分享。
相关仓库 Ubuntu安装源(ubuntu-releases): https://developer.aliyun.com/mirror/ubuntu-releases Ubuntu ARM源(ubuntu-ports): https://developer.aliyun.com/mirror/ubuntu-ports Ubuntu过期源(oldubuntu-releases): https://developer.aliyun.com/mirror/oldubuntu-releases Ubuntu其他架构安装镜像(ubuntu-cdimage): https://developer.aliyun.com/mirror/ubuntu-cdimage
Ubuntu 22.04 ARM 镜像源
清华源
纯文本
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse

apt 配置代理

sudo apt-get -o Acquire::http::proxy="socks5h://127.0.0.1:1080/" update

NPM

npm / yarn 配置淘宝源

纯文本
# ==========================================================
# NPM
# ==========================================================

npm set registry https://registry.npmmirror.com # 注册模块镜像
npm set disturl https://npmmirror.com/mirrors/node # node-gyp 编译依赖的 node 源码镜像

## 以下选择添加
npm set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://registry.npmmirror.com/mirrors/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://registry.npmmirror.com/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://registry.npmmirror.com/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://registry.npmmirror.com/mirrors/operadriver # operadriver 二进制包镜像
npm set phantomjs_cdnurl https://registry.npmmirror.com/mirrors/phantomjs # phantomjs 二进制包镜像
npm set selenium_cdnurl https://registry.npmmirror.com/mirrors/selenium # selenium 二进制包镜像
npm set node_inspector_cdnurl https://registry.npmmirror.com/mirrors/node-inspector # node-inspector 二进制包镜像
npm set sentrycli_cdnurl https://npmmirror.com/mirrors/sentry-cli/ # sentry-cli

npm cache clean --force # 清空缓存

# ==========================================================
# YARN
# ==========================================================

yarn config set registry https://registry.npmmirror.com # 注册模块镜像
yarn config set disturl https://npmmirror.com/mirrors/node # node-gyp 编译依赖的 node 源码镜像

## 以下选择添加
yarn config set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像
yarn config set electron_mirror https://registry.npmmirror.com/mirrors/electron/ # electron 二进制包镜像
yarn config set puppeteer_download_host https://registry.npmmirror.com/mirrors # puppeteer 二进制包镜像
yarn config set chromedriver_cdnurl https://registry.npmmirror.com/mirrors/chromedriver # chromedriver 二进制包镜像
yarn config set operadriver_cdnurl https://registry.npmmirror.com/mirrors/operadriver # operadriver 二进制包镜像
yarn config set phantomjs_cdnurl https://registry.npmmirror.com/mirrors/phantomjs # phantomjs 二进制包镜像
yarn config set selenium_cdnurl https://registry.npmmirror.com/mirrors/selenium # selenium 二进制包镜像
yarn config set node_inspector_cdnurl https://registry.npmmirror.com/mirrors/node-inspector # node-inspector 二进制包镜像
yarn config set sentrycli_cdnurl https://npmmirror.com/mirrors/sentry-cli/ # sentry-cli

yarn cache clean # 清空缓存

npm 配置源

npm config set registry https://registry.npmjs.org/ npm config set registry http://mirrors.cloud.tencent.com/npm/

yarn 配置源

yarn config set registry https://registry.npmmirror.com/ 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

Yarn

Git标签
如果你在Git仓库中运行yarn version,Git标签默认会在格式之后创建v0.0.0。
您可以使用yarn config set自定义创建的git标记或禁用此行为。
要更改git标签的前缀,您可以使用version-tag-prefix:
纯文本
yarn config set version-tag-prefix "v"
或者,您可以使用version-git-message 其中%s版本字符串来更改git消息
纯文本
yarn config set version-git-message "v%s"
您还可以使用version-sign-git-tag以下功能开启或关闭签署git标签:
纯文本
yarn config set version-sign-git-tag false
您甚至可以完全使用version-git-tag启用或禁用git标记行为:
纯文本
yarn config set version-git-tag false

Github

Github国内加速克隆及下载 fastgit.org https://doc.fastgit.org/

克隆加速

release下载加速

#免替换方法
查看git配置信息
git config --global --list
取消设置
git config --global --unset url.https://github.com/.insteadof

raw文件下载加速

提供web界面的github资源加速网站:

GitHub 文件加速:https://gh.api.99988866.xyz/
Github仓库加速:https://github.zhlh6.cn/
Github仓库加速:http://toolwa.com/github/

Docker

1. 安装/升级Docker客户端

推荐安装1.10.0以上版本的Docker客户端,参考文档 docker-ce

2. 配置镜像加速器

针对Docker客户端版本大于 1.10.0 的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
Bash
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
docker 镜像源代理
源站
替换为
平台
docker.io
dockerhub.jansora.app
docker hub
gcr.io
gcr.jansora.app
Google Container Registry
ghcr.io
ghcr.jansora.app
GitHub Container Registry
k8s.gcr.io
k8s-gcr.jansora.app
Kubernetes Container Registry
registry.k8s.io
k8s.jansora.app
Kubernetes's container image registry
quay.io
quay.jansora.app
Quay Container Registry
mcr.microsoft.com
mcr.jansora.app
Microsoft Container Registry
docker.elastic.co
elastic.jansora.app
Elastic Stack
nvcr.io
nvcr.jansora.app
NVIDIA Container Registry

Go

纯文本
# 启用 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

————————————————
原文作者:Summer
转自链接:https://learnku.com/go/wikis/38122
版权声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请保留以上作者信息和原文链接。

评论栏

分享你的想法,或参与下面的讨论。

参与讨论

支持 Markdown、代码和图片

撰写评论
正在加载编辑器…

友善交流,让讨论更有价值。

更多留言

加载中…