目录
1. Node.js / npm 镜像
针对Node.js和npm,国内常用的镜像是淘宝的 npm 镜像源(cnpm),可以加速下载Node.js模块。
- 淘宝 npm 镜像 (cnpm):
npm config set registry https://registry.npmmirror.com
- 或者可以使用 cnpm 命令行工具:
npm install -g cnpm --registry=https://registry.npmmirror.com
2. Python / pip 镜像
Python的包管理工具 pip
可以配置使用国内的PyPI镜像源,如豆瓣、清华、阿里云等。
- 豆瓣镜像:
pip install -i https://pypi.doubanio.com/simple some-package
- 清华大学镜像:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
-
阿里云镜像:
pip install -i https://mirrors.aliyun.com/pypi/simple some-package
3. Maven / Gradle(Java)
除了前面提到的Gradle镜像,Maven也可以配置国内镜像源,常见的有阿里云、华为云、清华大学等。
-
阿里云 Maven 仓库:
<mirror>
<id>aliyun</id>
<mirrorOf>central</mirrorOf>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
-
清华大学 Maven 仓库:
<mirror>
<id>tsinghua</id>
<mirrorOf>central</mirrorOf>
<url>https://mirrors.tuna.tsinghua.edu.cn/repository/maven/</url>
</mirror>
4. Rust / crates.io 镜像
Rust使用 cargo
来管理包依赖,可以配置国内的 crates.io 镜像。
-
清华大学 Rust 镜像:
在
~/.cargo/config
中添加以下内容:
[source.crates-io]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index"
5. Go / goproxy 镜像
Go语言可以通过 goproxy
配置国内的代理,加速模块的下载。
-
Go 中国代理:
go env -w GOPROXY=https://goproxy.cn,direct
6. Composer(PHP)镜像
PHP的包管理工具Composer也有国内镜像源,可以加速依赖下载。
-
阿里云 Composer 镜像:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
- 中国全量镜像(packagist.cn):
composer config -g repo.packagist composer https://packagist.cn
7. Docker 镜像
Docker使用的镜像仓库有国内加速镜像,比如阿里云、网易、DaoCloud等。
-
阿里云Docker镜像加速:
可以在阿里云容器服务中获取加速地址,然后在
/etc/docker/daemon.json
中配置:{ "registry-mirrors": ["https://<your_accelerator>.mirror.aliyuncs.com"] }
DaoCloud Docker 加速器:
{ "registry-mirrors": ["http://f1361db2.m.daocloud.io"] }
8. Ruby / RubyGems 镜像
Ruby的包管理工具
gem
可以配置使用国内镜像源。 -
Ruby China 镜像:
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/