创建目录 ~/.gradle/init.d
(Unix/Linux 环境)或 %USERPROFILE%\.gradle\init.d
(Windows 环境),写入以下两个文件:
repo.gradle
:allprojects { buildscript { repositories { maven { url "https://repo.huaweicloud.com/repository/maven" } } } repositories { maven { url "https://repo.huaweicloud.com/repository/maven" } } gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } tasks.withType(GroovyCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } } }
pluginManagement.gradle
(只对 Gradle 4.0 及以上版本使用新的 plugins {} DSL 部分有效):settingsEvaluated { settings -> settings.pluginManagement { repositories { maven { url "https://repo.huaweicloud.com/repository/maven" } gradlePluginPortal() } } }
./gradlew --refresh-dependencies build
创建 ~/.m2/settings.xml
(Linux/Unix 环境) 或 %USERPROFILE%\.m2\settings.xml
(Windows 环境) 文件,写入以下内容:
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <mirror> <id>huaweicloud</id> <mirrorOf>*</mirrorOf> <url>https://repo.huaweicloud.com/repository/maven</url> </mirror> </mirrors> </settings>
创建 ~/.groovy/grapeConfig.xml
(Linux/Unix 环境) 或 %USERPROFILE%\.groovy\grapeConfig.xml
(Windows 环境) 文件,写入以下内容:
<ivysettings> <settings defaultResolver="downloadGrapes"/> <resolvers> <chain name="downloadGrapes" returnFirst="true"> <filesystem name="cachedGrapes"> <ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/> <artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/> </filesystem> <ibiblio name="localm2" root="${user.home.url}/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true"/> <ibiblio name="huawei" root="https://mirrors.huaweicloud.com/repository/maven" m2compatible="true"/> </chain> </resolvers> </ivysettings>
配置 nvm 环境变量:
NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node NVM_IOJS_ORG_MIRROR=http://npm.taobao.org/mirrors/iojs
执行命令:
npm config set registry https://registry.npm.taobao.org npm config set disturl https://npm.taobao.org/dist npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs npm config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver npm config set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver npm config set electron_mirror https://npm.taobao.org/mirrors/electron/ npm config set python_mirror https://npm.taobao.org/mirrors/python npm config set electron_builder_binaries_mirror https://npm.taobao.org/mirrors/electron-builder-binaries/ npm config set node_sqlite3_binary_host_mirror https://npm.taobao.org/mirrors
手改~/.npmrc或设置等效的环境变量均有效。
特别注意,如果想要发布 npm 包到中央仓库,必须先取消设置 registry,发布完毕之后再改回来:
# 发布中央仓库之前必须取消registry镜像设置 npm config delete registry # 发布完毕再把registry镜像加回来 npm config set registry https://registry.npm.taobao.org
执行命令:
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
执行命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main conda config --set show_channel_urls yes
修改 .condarc
配置文件可以达成同样的效果,参考下方参考资料:
通过镜像站安装插件:
vagrant plugin install --plugin-clean-sources --plugin-source https://gems.ruby-china.com/ <plugin>...
vagrant-vbguest 下载 VBoxGuestAdditions 镜像 (修改 Vagrantfile):
config.vbguest.iso_path = "https://mirrors.tuna.tsinghua.edu.cn/virtualbox/%{version}/VBoxGuestAdditions_%{version}.iso"
通过镜像站下载 box:
# Ubuntu镜像 vagrant init ubuntu-bionic https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-amd64-vagrant.box # Centos镜像 vagrant init centos7 https://mirrors.ustc.edu.cn/centos-cloud/centos/7/vagrant/x86_64/images/CentOS-7.box
也可以修改 Vagrantfile 的 config.vm.box_url = "box file url"
。
设置 rustup
环境变量:
RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
写入配置文件 ~/.cargo/config
:
[source.crates-io] replace-with = 'ustc' [source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index"
中科大提供了公开的 Docker Hub 仓库镜像,以下配置以中科大为例。其他国内的云厂商如阿里云、华为云等等都提供了 Docker Hub 镜像,需要用户自行注册账号,并且手工开通,使用是免费的。如果期望使用云厂商免费的 Docker Hub 镜像,替换下面的镜像地址为云厂商分配给用户的加速地址即可。
在 /etc/docker/daemon.json
中加入:
{ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"] }
重启服务即可。
在系统右下角托盘 Docker 图标内右键菜单选择 Settings ,打开配置窗口后左侧导航菜单选择 Daemon 。在 Registry mirrors 一栏中填写地址 https://docker.mirrors.ustc.edu.cn ,之后点击 Apply 保存后 Docker 就会重启并应用配置的镜像地址了。
创建 ~/.julia/config/startup.jl
文件,写入以下内容:
using Pkg pkg"activate ." pkg"registry add https://mirrors.ustc.edu.cn/julia/registries/General.git" pkg"instantiate"