├── configs ├── .npmrc ├── daemon.json ├── rubygems.sh ├── init.gradle ├── conda.sh ├── .condarc └── pip.conf └── README.md /configs/.npmrc: -------------------------------------------------------------------------------- 1 | # ustc, doc: https://lug.ustc.edu.cn/wiki/mirrors/help/npm 2 | registry=http://npmreg.mirrors.ustc.edu.cn/ 3 | 4 | # taobao, doc: https://npm.taobao.org/ 5 | #registry=http://registry.npm.taobao.org/ 6 | -------------------------------------------------------------------------------- /configs/daemon.json: -------------------------------------------------------------------------------- 1 | // ustc, doc: https://lug.ustc.edu.cn/wiki/mirrors/help/docker 2 | { 3 | "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] 4 | } 5 | 6 | // docker-cn, doc: https://www.docker-cn.com/registry-mirror 7 | //{ 8 | // "registry-mirrors": ["https://registry.docker-cn.com"] 9 | //} 10 | -------------------------------------------------------------------------------- /configs/rubygems.sh: -------------------------------------------------------------------------------- 1 | # ustc, doc: https://mirrors.ustc.edu.cn/help/rubygems.html 2 | gem sources #列出默认源 3 | gem sources --remove https://rubygems.org/ #移除默认源 4 | gem sources -a https://mirrors.ustc.edu.cn/rubygems/ #添加科大源 5 | 6 | # thu, doc: https://mirror.tuna.tsinghua.edu.cn/help/rubygems/ 7 | #gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove #https://rubygems.org/ 8 | #gem sources -l 9 | -------------------------------------------------------------------------------- /configs/init.gradle: -------------------------------------------------------------------------------- 1 | // aliyun maven: https://maven.aliyun.com/mvn/view 2 | allprojects { 3 | buildscript { 4 | repositories { 5 | maven { url 'https://maven.aliyun.com/repository/google' } 6 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 7 | } 8 | } 9 | repositories { 10 | maven { url 'https://maven.aliyun.com/repository/google' } 11 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /configs/conda.sh: -------------------------------------------------------------------------------- 1 | # ustc, doc: https://mirrors.ustc.edu.cn/help/anaconda.html 2 | conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ 3 | conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ 4 | conda config --set show_channel_urls yes 5 | 6 | # thu, doc: https://mirror.tuna.tsinghua.edu.cn/help/anaconda/ 7 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 8 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ 9 | #conda config --set show_channel_urls yes 10 | -------------------------------------------------------------------------------- /configs/.condarc: -------------------------------------------------------------------------------- 1 | channels: 2 | - defaults 3 | show_channel_urls: true 4 | default_channels: 5 | - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main 6 | - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free 7 | - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r 8 | custom_channels: 9 | conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 10 | msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 11 | bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 12 | menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 13 | pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 14 | simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud -------------------------------------------------------------------------------- /configs/pip.conf: -------------------------------------------------------------------------------- 1 | # official doc: https://pip.pypa.io/en/stable/user_guide/ 2 | # file path: 3 | # Linux/MacOS: /etc/pip.conf, or ~/.config/pip.conf, or pip/pip.conf 4 | # Windows: c:/Users/xxx/pip/pip.ini 5 | 6 | # douban, may be the fastest 7 | #[global] 8 | # index-url = https://pypi.doubanio.com/simple 9 | 10 | 11 | # ustc, doc: https://lug.ustc.edu.cn/wiki/mirrors/help/pypi 12 | [global] 13 | index-url = https://mirrors.ustc.edu.cn/pypi/web/simple 14 | trusted-host=mirrors.ustc.edu.cn 15 | 16 | 17 | # thu, doc: https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ 18 | #[global] 19 | # index-url = https://pypi.tuna.tsinghua.edu.cn/simple 20 | # trusted-host=pypi.tuna.tsinghua.edu.cn 21 | 22 | 23 | # aliyun, doc: http://www.atjiang.com/aliyun-pip-mirror/ 24 | #[global] 25 | # index-url=http://mirrors.aliyun.com/pypi/simple 26 | # trusted-host=mirrors.aliyun.com 27 | 28 | 29 | # 163, no doc. 30 | #[global] 31 | # index-url=https://mirrors.163.com/pypi/simple 32 | # trusted-host=mirrors.163.com -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mirrors-china 2 | Mirrors and registries in China to speedup your package installation. 3 | 4 | 由于许多包的存放服务器在国外,国内安装比较慢,因此本文总结了常见的包(例如Python包,Linux不同发行版的包)在国内的开源镜像,加速你的下载,提高安装体验。下面总结了PyPi,Anacoda,NPM, Docker,RubyGems,Gradle和Linux的国内镜像。 5 | 6 | ## How to use 7 | ```bash 8 | git clone https://github.com/vra/mirrors-china 9 | cd mirror-china 10 | # update files in configs dir 11 | # copy config files to destination or run shell scripts to make them take effect 12 | ``` 13 | 14 | ## PyPi 加速 15 | 临时加速可以用下面的命令: 16 | ```bash 17 | pip install -i https://path/to/pypi/mirror package 18 | ``` 19 | 永久使用的话,如果pip版本升级到10.0以后,可以用下面到命令来一键永久修改: 20 | ```bash 21 | # 参考https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ 22 | pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 23 | ``` 24 | 也可以修改配置文件`pip.conf`: 25 | 26 | - Linux/MacOS配置文件:优先级从高到低 27 | - 系统级:`/etc/pip.conf` 28 | - 用户级:`~/.config/pip/pip.conf`或`~/.pip/pip.conf`,前者优先级比后者高 29 | - 虚拟环境级:虚拟环境根目录下`pip.conf` 30 | 31 | - Windows: 修改`c:/Users/xxx/pip/pip.ini` 32 | 33 | ```bash 34 | # official doc: https://pip.pypa.io/en/stable/user_guide/ 35 | # file path: 36 | # Linux/MacOS: /etc/pip.conf, or ~/.config/pip.conf, or pip/pip.conf 37 | # Windows: c:/Users/xxx/pip/pip.ini 38 | 39 | # douban, may be the fastest 40 | [global] 41 | index-url = https://pypi.doubanio.com/simple 42 | 43 | 44 | # ustc, doc: https://lug.ustc.edu.cn/wiki/mirrors/help/pypi 45 | #[global] 46 | # index-url = https://mirrors.ustc.edu.cn/pypi/web/simple 47 | # trusted-host=mirrors.ustc.edu.cn 48 | 49 | 50 | # thu, doc: https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ 51 | #[global] 52 | # index-url = https://pypi.tuna.tsinghua.edu.cn/simple 53 | # trusted-host=pypi.tuna.tsinghua.edu.cn 54 | 55 | 56 | # aliyun, doc: http://www.atjiang.com/aliyun-pip-mirror/ 57 | #[global] 58 | # index-url=http://mirrors.aliyun.com/pypi/simple 59 | # trusted-host=mirrors.aliyun.com 60 | 61 | 62 | # 163, no doc. 63 | #[global] 64 | # index-url=https://mirrors.163.com/pypi/simple 65 | # trusted-host=mirrors.163.com 66 | 67 | # tencent, doc: https://mirrors.cloud.tencent.com/help/pypi.html 68 | #[global] 69 | # index-url=https://mirrors.cloud.tencent.com/pypi/simple 70 | # trusted-host=mirrors.cloud.tencent.com 71 | ``` 72 | 73 | 本文中默认用的中科大的源,实际使用的时候,选择自己访问最快的**一个**镜像就可以了,将别的镜像设置注释掉或者删掉。 74 | 75 | 76 | ## Anaconda 包加速 77 | Anaconda是一个Python的包管理系统,包含科学计算常用的包。通过在命令行执行下面的文件就可以使用中科大或者清华的Anaconda镜像了,注意只执行自己访问最快的镜像对应的命令。 78 | ```bash 79 | # run this script in terminal 80 | # ustc, doc: https://mirrors.ustc.edu.cn/help/anaconda.html 81 | conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ 82 | conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ 83 | conda config --set show_channel_urls yes 84 | 85 | # thu, doc: https://mirror.tuna.tsinghua.edu.cn/help/anaconda/ 86 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 87 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ 88 | #conda config --set show_channel_urls yes 89 | ``` 90 | 91 | 或者,可以通过自行编辑配置文件`.condarc`来进行设定: 92 | 93 | - Linux/MacOS: `~/.condarc` 94 | 95 | - Windows: `c:/Users/xxx/.condarc` 96 | 97 | ```bash 98 | # thu, doc: https://mirror.tuna.tsinghua.edu.cn/help/anaconda/ 99 | channels: 100 | - defaults 101 | show_channel_urls: true 102 | default_channels: 103 | - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main 104 | - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free 105 | - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r 106 | custom_channels: 107 | conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 108 | msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 109 | bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 110 | menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 111 | pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 112 | simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 113 | ``` 114 | 115 | ## NPM 包加速 116 | NPM 是NodeJs的包管理系统,NodeJs的包通过该命令来安装。临时使用镜像来安装某个包可以用下面的命令: 117 | ```bash 118 | $ npm --registry http://path/to/npm/mirror install package 119 | ``` 120 | 永久使用某个镜像需要修改`~/.npmrc`,加入下面的某一个镜像即可: 121 | ```bash 122 | # file path: ~/.npmrc 123 | # ustc, doc: https://lug.ustc.edu.cn/wiki/mirrors/help/npm 124 | registry=http://npmreg.mirrors.ustc.edu.cn/ 125 | 126 | # taobao, doc: https://npm.taobao.org/ 127 | #registry=http://registry.npm.taobao.org/ 128 | ``` 129 | 130 | ## Docker 镜像加速 131 | 修改`/etc/docker/daemon.json`,加入下面的内容: 132 | ```js 133 | // ustc, doc: https://lug.ustc.edu.cn/wiki/mirrors/help/docker 134 | { 135 | "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] 136 | } 137 | 138 | // docker-cn, doc: https://www.docker-cn.com/registry-mirror 139 | //{ 140 | // "registry-mirrors": ["https://registry.docker-cn.com"] 141 | //} 142 | ``` 143 | 144 | ## RubyGems 加速 145 | ```bash 146 | # run this script in terminal 147 | # ustc, doc: https://mirrors.ustc.edu.cn/help/rubygems.html 148 | gem sources #列出默认源 149 | gem sources --remove https://rubygems.org/ #移除默认源 150 | gem sources -a https://mirrors.ustc.edu.cn/rubygems/ #添加科大源 151 | 152 | # thu, doc: https://mirror.tuna.tsinghua.edu.cn/help/rubygems/ 153 | #gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove #https://rubygems.org/ 154 | #gem sources -l 155 | ``` 156 | 157 | ## Gradle 包加速 158 | Android Studio基于gradle构建,可使用aliyun的maven仓库进行加速。为所有Android Studio项目做配置,先定位`$GRADLE_USER_HOME`所在目录: 159 | 160 | - Windows:默认位于`C:\Users\\.gradle` 161 | - Linux:默认位于`$HOME\.gradle` 162 | - 特别声明了`$GRADLE_USER_HOME`环境变量,或在`Android Studio安装目录/bin/idea.properties`中声明了`gradle.user.home`变量:声明所在目录 163 | 164 | 在`$GRADLE_USER_HOME`(或idea.properties中的`gradle.user.home`)目录下,新建init.gradle文件(或从本仓库config/init.gradle拷贝),内容如下: 165 | 166 | ```groovy 167 | // aliyun maven: https://maven.aliyun.com/mvn/view 168 | allprojects { 169 | buildscript { 170 | repositories { 171 | maven { url 'https://maven.aliyun.com/repository/google' } 172 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 173 | } 174 | } 175 | repositories { 176 | maven { url 'https://maven.aliyun.com/repository/google' } 177 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 178 | } 179 | } 180 | ``` 181 | 重启AS以生效;或将上述配置临时修改与当前AS项目的build.gradle文件中以生效。 182 | 183 | ## Git 仓库加速 184 | [码云](http://gitee.com)提供了导入git仓库功能。对于最常用的github上的仓库,可在[码云极速下载](https://gitee.com/mirrors)查看已有镜像,或注册账号后自行新建repo从github导入,以加速访问。 185 | 186 | ## Linux 包加速 187 | 由于Linux发行版众多,配置各不相同,因此请参考下面的源下面的文档进行对应发行版的配置: 188 | 1. 中科大: 189 | 2. 清华: 190 | 3. aliyun: 191 | 4. 163: 192 | --------------------------------------------------------------------------------