概述
本文档包含了各个常用镜像服务及对应镜像站
各个镜像源的帮助文档:
清华:https://mirror.tuna.tsinghua.edu.cn/help
阿里云:https://developer.aliyun.com/mirror/
中科大:https://mirrors.ustc.edu.cn/help/
华为云:https://mirrors.huaweicloud.com/home
系统软件源
Debian
查看系统发行版本
清华
Debian12:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
cat << EOF | sudo tee /etc/apt/sources.list > /dev/null
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
|
Debain10:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
# deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# # deb-src http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
deb http://security.debian.org/debian-security buster/updates main contrib non-free
# deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
|
PyPI
清华
临时使用
1
|
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package_name
|
设为默认
1
2
|
python -m pip install --upgrade pip
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
阿里
公网配置方法:
- 找到下列文件
- 在上述文件中添加或修改:
1
2
3
4
5
|
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
|
ECS内网配置方法:
- 找到下列文件
- 在上述文件中添加或修改:
1
2
3
4
5
|
[global]
index-url=http://mirrors.cloud.aliyuncs.com/pypi/simple/
[install]
trusted-host=mirrors.cloud.aliyuncs.com
|
NPM
查看镜像源
1
|
npm config get registry
|
删除镜像源
淘宝
http://npm.taobao.org
和 http://registry.npm.taobao.org
将在 2022.06.30 号正式下线和停止 DNS 解析。
新域名为 npmmirror.com
, 相关服务域名切换规则请参考:
1
|
npm config set registry https://registry.npmmirror.com
|
yarn
查看镜像源
1
|
yarn config get registry
|
设置为淘宝镜像源
1
|
yarn config set registry https://registry.npmmirror.com
|
删除镜像源
1
|
yarn config rm registry
|
华为云
- 切换
1
|
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
|
- 验证
1
|
npm config get registry
|
Go
七牛云
1
2
|
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
|
Maven
阿里云
打开 Maven 的配置文件(windows机器一般在maven安装目录的conf/settings.xml),在<mirrors></mirrors>
标签中添加 mirror 子节点:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
|
Docker软件源
非 Docker Hub镜像源
清华
Debian/Ubuntu/Raspbian 用户
以下内容根据 官方文档 修改而来。
如果你过去安装过 docker,先删掉:
1
|
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
|
首先安装依赖:
1
2
|
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
|
信任 Docker 的 GPG 公钥并添加仓库:
如果为Ubuntu、Raspbian,请查看 https://mirror.tuna.tsinghua.edu.cn/help/docker-ce/
1
2
3
4
5
6
7
8
9
10
|
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
如果提示
1
2
|
-bash: gpg: command not found
curl: (23) Failed writing body
|
请安装 gpg 之后,再次尝试上述的步骤: 信任 Docker 的 GPG 公钥并添加仓库
最后安装
1
2
3
|
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
Gradle
腾讯云(推荐,版本全)
1
|
https://mirrors.cloud.tencent.com/gradle
|
阿里云(有些小版本没有)
1
|
https://mirrors.aliyun.com/macports/distfiles/gradle/
|