前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >开发常用的各种镜像站

开发常用的各种镜像站

作者头像
码客说
发布2019-10-22 16:58:09
2.5K0
发布2019-10-22 16:58:09
举报
文章被收录于专栏:码客码客

Yum镜像

(1) 备份

代码语言:javascript
复制
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

(2) 查看系统版本

代码语言:javascript
复制
cat /etc/redhat-release

(3) 下载

下载新的CentOS-Base.repo 到/etc/yum.repos.d/

  • CentOS 7 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  • CentOS 6 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  • CentOS 5 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

(4) 生成缓存

代码语言:javascript
复制
yum makecache

Android镜像

方式一 修改 hosts 文件

在使用 Android SDK Manager 的时候,主要会连接到两个地址 dl.google.comdl-ssl.google.com

可以发现这两个地址都是无法正常访问的,如何解决呢?

我们可以通过修改 hosts 文件,将上面的地址定向到能正常访问的 Google 服务器。

我们可以使用站长工具的超级 ping 来查找可用IP。

打开地址:http://ping.chinaz.com/,分别测试 dl.google.comdl-ssl.google.com 的IP地址,

将获取到的IP写入以下文件

  • Win C:\Windows\System32\drivers\etc\hosts
  • Mac /private/etc/hosts

方式二 使用国内镜像源

Maven镜像

可用镜像

阿里云的镜像站(首推,新站,速度暴快)

代码语言:javascript
复制
<mirror>
    <id>nexus-aliyun</id>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
</mirror>

leancloud

代码语言:javascript
复制
<mirror>
    <id>nexus-leancloud</id>
    <name>Nexus leancloud</name>
    <url>http://mvn.leancloud.cn/nexus/content/repositories/public</url>
    <mirrorOf>central</mirrorOf>
</mirror>

ibiblio

代码语言:javascript
复制
<mirror>
     <id>ibiblio.org</id>
     <name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
     <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
     <mirrorOf>central</mirrorOf>
</mirror>

JBoss的仓库

代码语言:javascript
复制
<mirror>
    <id>jboss-public-repository-group</id>
    <mirrorOf>central</mirrorOf>
    <name>JBoss Public Repository Group</name>
    <url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>

使用方式

修改~/.m2文件夹下的settings.xml文件,

<mirrors>标签下加入上述内容即可。如下:

代码语言:javascript
复制
<?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>nexus-aliyun</id>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </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>
    </mirrors>
</settings>

Maven仓库

阿里云

代码语言:javascript
复制
<repository>
    <id>maven-ali</id>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
    </snapshots>
</repository>

sonatype

代码语言:javascript
复制
<repository>
	<id>oss-sonatype-snapshots</id>
	<name>OSS Sonatype Snapshots Repository</name>
	<url>http://oss.sonatype.org/content/repositories/snapshots</url>
	<releases>
		<enabled>false</enabled>
	</releases>
	<snapshots>
		<enabled>true</enabled>
	</snapshots>
</repository>

sun

代码语言:javascript
复制
<repository>
	<id>sun</id>
	<name>sun</name>
	<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
	<releases>
		<enabled>false</enabled>
	</releases>
	<snapshots>
		<enabled>true</enabled>
	</snapshots>
</repository>

alfresco

代码语言:javascript
复制
<repository>
	<id>alfresco.public</id>
	<name>Alfresco Public Repository</name>
	<url>https://maven.alfresco.com/nexus/content/groups/public</url>
	<releases>
		<enabled>true</enabled>
	</releases>
	<snapshots>
		<enabled>false</enabled>
	</snapshots>
</repository>

spring

代码语言:javascript
复制
<repository>
	<id>springsource-repo</id>
	<name>SpringSource Repository</name>
	<url>http://repo.springsource.org/release</url>
</repository>

Ruby镜像

RubyGems 镜像

代码语言:javascript
复制
gem sources -l
gem sources --add http://gems.ruby-china.com/ --remove https://rubygems.org/

gem sources -l
*** CURRENT SOURCES ***

http://gems.ruby-china.com/
# 请确保只有 gems.ruby-china.com
gem install rails

如果你使用 Gemfile 和 Bundler (例如:Rails 项目)

代码语言:javascript
复制
bundle config mirror.https://rubygems.org http://gems.ruby-china.com

这样你不用改你的 Gemfile 的 source。

Flutter国内镜像

代码语言:javascript
复制
git clone -b beta https://github.com/flutter/flutter.git
export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
export PATH=`pwd`/flutter/bin:$PATH

Homebrew镜像

使用替换默认源

第一步:替换brew.git

代码语言:javascript
复制
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

第二步:替换homebrew-core.git

代码语言:javascript
复制
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
cd 
brew update

第三步:替换Homebrew Bottles

Homebrew是OS X系统的一款开源的包管理器。出于节省时间的考虑,Homebrew默认从Homebrew Bottles源中下载二进制代码包安装。Homebrew Bottles是Homebrew提供的二进制代码包,目前镜像站收录了以下仓库: homebrew/homebrew-core homebrew/homebrew-dupes homebrew/homebrew-games homebrew/homebrew-gui homebrew/homebrew-python homebrew/homebrew-php homebrew/homebrew-science homebrew/homebrew-versions homebrew/homebrew-x11

对于bash用户:

代码语言:javascript
复制
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile

立即生效

代码语言:javascript
复制
source ~/.bash_profile

对于zsh用户:

代码语言:javascript
复制
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc

立即生效

代码语言:javascript
复制
source ~/.zshrc

换回官方源

第一步:重置brew.git

代码语言:javascript
复制
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

第二步:重置homebrew-core.git

代码语言:javascript
复制
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
cd
brew update

第三步:注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-08-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Yum镜像
  • Android镜像
    • 方式一 修改 hosts 文件
      • 方式二 使用国内镜像源
      • Maven镜像
        • 可用镜像
          • 使用方式
          • Maven仓库
          • Ruby镜像
          • Flutter国内镜像
          • Homebrew镜像
            • 使用替换默认源
              • 换回官方源
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档