Skip to content

随记

多尝试后再问人。

很多软件在使用过程中,默认的软件源/仓库地址,由于是国外的,下载非常慢,因此需要配置国内源,这里记录一下常用软件源配置方法,默认修改为阿里源

maven

xml
<settings>
    <!--需要改成自己的maven的本地仓库地址-->
    <localRepository>/Users/shafulin/repository</localRepository>
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
</settings>

centos

参考文档

  • centos7,修改为阿里源
shell
# 1. 备份软件源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 2. 下载阿里源配置,以下两条命令可任选其一
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 3. 生成缓存
yum makecache

npm,yarm

shell
# npm
npm config set registry https://registry.npmmirror.com
# yarn
yarn config set registry http://registry.npmmirror.com

单独资源引入

访问https://npmmirror.com/,然后自由搜索你要的库, 例如vue引入格式 https://unpkg.com/库@版本/目录/文件名 ,例如

shell
https://unpkg.com/vue@3/dist/vue.global.js

Python-pip

Python pip更换国内源(一句命令换源)

pip国内的一些镜像

站点名国内源地址
阿里云http://mirrors.aliyun.com/pypi/simple/
中国科技大学https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban)http://pypi.douban.com/simple/
清华大学https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学http://pypi.mirrors.ustc.edu.cn/simple/
shell
# 临时使用: 可以在使用pip的时候在后面加上-i参数,指定pip源 
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
# 永久修改:一句命令换源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

linux

修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

shell
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
EOF

win

直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下

shell
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

docker

阿里云镜像加速

shell
# 配置加速器
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
    "https://docker.1ms.run",
    "https://7jdhwfuo.mirror.aliyuncs.com",
    "https://docker.m.daocloud.io",
    "https://dockerproxy.com"
  ]
}
EOF
# 重新加载配置
sudo systemctl daemon-reload
# 重启docker服务
sudo systemctl start docker

jenkins

初始化后

在插件管理里,修改软件源为清华源

https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

初始化时

  1. 修改.jenkins目录中的hudson.model.UpdateCenter.xml文件为:
xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
    <site>
        <id>default</id>
        <url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
    </site>
</sites>
  1. 修改.jenkins/jenkins_home/updates/default.json文件 替换文件中所有以下关键字
  • https://updates.jenkins-ci.org/download 修改为 https://mirrors.tuna.tsinghua.edu.cn/jenkins
  • https://updates.jenkins.io/download 修改为 https://mirrors.tuna.tsinghua.edu.cn/jenkins
  • http://www.google.com 修改为 http://www.baidu.com
  1. 在浏览器中,http://IP:8080/reload ,这样可以重新载入配置。

    访问 http://localhost:8080/reload ,重启一下Jenkins ,选择安装推荐插件, 秒速安装成功,简直超速!!

homebrew配置清华源

1.编辑~/.zshrc

shell
# ========== Homebrew 清华国内镜像完整配置 ==========
# 二进制包镜像
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
# API 镜像
export HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api
# git 源码仓库远程
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_CASK_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git"
# 屏蔽github官方接口,不走外网
export HOMEBREW_NO_GITHUB_API=1
# 本地不走代理
export no_proxy=localhost,127.0.0.1,::1
export NO_PROXY=localhost,127.0.0.1,::1

2.重载配置

shell
source ~/.zshrc

# 绑定清华git仓库
git -C "$(brew --repo)" remote set-url origin $HOMEBREW_BREW_GIT_REMOTE
git -C "$(brew --repo homebrew/core)" remote set-url origin $HOMEBREW_CORE_GIT_REMOTE
git -C "$(brew --repo homebrew/cask)" remote set-url origin $HOMEBREW_CASK_GIT_REMOTE

3.清理缓存

shell
rm -rf ~/Library/Caches/Homebrew
brew cleanup
brew update

Released under the MIT License.