常用的几个网站
华为镜像站
https://mirrors.huaweicloud.com/home
阿里镜像站
https://developer.aliyun.com/mirror/
腾讯镜像站
https://mirrors.cloud.tencent.com/
Yum镜像
(1) 备份
1 | mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup |
(2) 查看系统版本
1 | cat /etc/redhat-release |
(3) 下载
下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 7
1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 6
1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 5
1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
(4) 生成缓存
1 | yum makecache |
Homebrew镜像
安装Brew
1 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
旧版本更新到新版
1 | brew update-reset |
使用替换默认源
替换 Homebrew
1 | git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git |
替换 Homebrew Core
1 | git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git |
替换 Homebrew Cask
1 | git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git |
替换 Homebrew-bottles
对于 bash 用户:
1 | echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile |
对于 zsh 用户:
1 | echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc |
换回官方源
第一步:重置brew.git
1 | cd "$(brew --repo)" |
第二步:重置homebrew-core.git
1 | cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" |
第三步:注释掉bash配置文件里的有关Homebrew Bottles
即可恢复官方源。 重启bash或让bash重读配置文件。
APT镜像
1.先备份原始软件源
1 | sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup |
2.编辑source.list
文件
1 | sudo vim /etc/apt/sources.list |
3.修改软件源为国内镜像(任选其一)
清华大学镜像
1 | deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted |
中科大镜像
1 | deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse |
更新软件源
1 | sudo apt-get update |
参考
清华大学Ubuntu镜像使用帮助
中科大Ubuntu源使用帮助
Android SDK镜像
方式一 修改 hosts 文件
在使用 Android SDK Manager
的时候,主要会连接到两个地址 dl.google.com
和 dl-ssl.google.com
,
可以发现这两个地址都是无法正常访问的,如何解决呢?
我们可以通过修改 hosts 文件,将上面的地址定向到能正常访问的 Google 服务器。
我们可以使用站长工具的超级 ping
来查找可用IP。
打开地址:http://ping.chinaz.com/,分别测试 dl.google.com
和 dl-ssl.google.com
的IP地址,
将获取到的IP写入以下文件
Win
C:\Windows\System32\drivers\etc\hosts
Mac
/private/etc/hosts
方式二 使用国内镜像源
mirrors.neusoft.edu.cn:80 //东软信息学院
Gradle镜像
Android项目我们常用Gradle来下载依赖
找到对应的地方修改即可,修改后重新构建。
找到项目下的build.gradle
文件
1 | buildscript { |
Maven镜像
可用镜像
阿里云的镜像站(首推,新站,速度暴快)
1 | <mirror> |
leancloud1
2
3
4
5
6<mirror>
<id>nexus-leancloud</id>
<name>Nexus leancloud</name>
<url>http://mvn.leancloud.cn/nexus/content/repositories/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
ibiblio
1 | <mirror> |
JBoss的仓库
1 | <mirror> |
使用方式
修改~/.m2
文件夹下的settings.xml
文件,
在<mirrors>
标签下加入上述内容即可。如下:
1 |
|
Maven仓库
阿里云
1 | <repository> |
sonatype
1 | <repository> |
sun
1 | <repository> |
alfresco
1 | <repository> |
spring
1 | <repository> |
Ruby镜像
1 | gem sources -l |
如果你使用 Gemfile 和 Bundler (例如:Rails 项目)
1 | bundle config mirror.https://rubygems.org http://gems.ruby-china.com |
这样你不用改你的 Gemfile 的 source。
Flutter国内镜像
1 | git clone -b beta https://github.com/flutter/flutter.git |
Flutter依赖镜像
修改Flutter的配置
该文件在Flutter安装目录/packages/flutter_tools/gradle/flutter.gradle
1 | buildscript { |
修改项目下配置
该文件在项目中android/build.gradle
1 | buildscript { |
NPM镜像
1 | npm config set registry https://registry.npmmirror.com |
还原默认
1 | npm config set registry https://registry.npmjs.org |
如下命令设置:
1 | npm config set registry https://repo.huaweicloud.com/repository/npm/ |
华为开源镜像站同时也提供了工具类加速镜像,可以通过如下的命令设置加速地址:
※ 设置nodejs工具的镜像地址
1 | npm config set disturl https://repo.huaweicloud.com/nodejs |
※ 设置Node-Sass的镜像地址
1 | npm config set sass_binary_site https://repo.huaweicloud.com/node-sass |
※ 设置浏览器引擎驱动镜像地址
1 | npm config set phantomjs_cdnurl https://repo.huaweicloud.com/phantomjs |
※ 设置Electron和Python的镜像地址
1 | npm config set electron_mirror https://repo.huaweicloud.com/electron/ |
Electron镜像
查看配置文件的位置
1 | npm config list |
可以查看到本机的userconfig
在哪,即.npmrc
文件在哪
比如我的
userconfig C:\Users\Jian.npmrc
打开该文件 添加
1 | registry=https://registry.npmmirror.com |
仅适用于中国区客户
MacOS
1 | # macOS |
Windows
1 | # Windows |
Docker镜像
Yum中Docker镜像
1 | # 卸载旧版本(如果安装过旧版本的话) |
针对Docker客户端版本大于 1.10.0 的用户
创建或修改 /etc/docker/daemon.json
文件
1 | vi /etc/docker/daemon.json |
添加或修改
1 | { |
重启Docker
1 | systemctl daemon-reload |
其他可用镜像源
ustc
https://docker.mirrors.ustc.edu.cn
阿里云镜像搜索地址
https://cr.console.aliyun.com/
SBT镜像
SBT的仓库配置文件位置为:~/.sbt/repositories,您可以点击此处直接下载配置文件。您也可以在~/.sbt/目录下新建repositories文件,添加如下内容:
1 | [repositories] |
在<sbt安装目录>/conf/sbtconfig.txt文件中添加如下内容:
1 | -Dsbt.override.build.repos=true |
如果是使用IDEA
在VM parameters中添加配置
Python镜像
常用地址
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
注意:
新版ubuntu要求使用https源,要注意。
临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:
1 | pip install -i http://mirrors.aliyun.com/pypi/simple/ deepface |
这样就会从清华这边的镜像去安装pyspider库。
永久修改:
Linux下,修改 ~/.pip/pip.conf
(没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
1 | [global] |
windows下,直接在User目录中创建一个pip
目录,再新建文件pip.ini
。(例如:C:\Users\WQP\pip\pip.ini)内容同上。
注意
不建议用阿里云的镜像,限速限的厉害。