配置国内源
沙福林 2024-01-22 20:21:59
国内源
npm
maven
镜像加速
centos
deepin
很多软件在使用过程中,默认的软件源/仓库地址,由于是国外的,下载非常慢,因此需要配置国内源,这里记录一下常用软件源配置方法,默认修改为阿里源
# maven
<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>
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# centos
- centos7,修改为阿里源
# 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
1
2
3
4
5
6
7
2
3
4
5
6
7
# npm,yarm
# npm
npm config set registry https://registry.npmmirror.com
# yarn
yarn config set registry http://registry.npmmirror.com
1
2
3
4
2
3
4
# 单独资源引入
访问https://npmmirror.com/ (opens new window),然后自由搜索你要的库,
例如vue引入格式 https://unpkg.com/库@版本/目录/文件名 ,例如
https://unpkg.com/vue@3/dist/vue.global.js
1
# Python-pip
Python pip更换国内源(一句命令换源) (opens new window)
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/ |
# 临时使用: 可以在使用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
1
2
3
4
2
3
4
# linux
修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
EOF
1
2
3
4
2
3
4
# win
直接在user目录中创建一个pip目录,如:
C:\Users\xx\pip,新建文件pip.ini,内容如下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
1
2
2
# docker
# 配置加速器
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://7jdhwfuo.mirror.aliyuncs.com"]
}
EOF
# 重新加载配置
sudo systemctl daemon-reload
# 重启docker服务
sudo systemctl start docker
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# jenkins
# 初始化后
在插件管理里,修改软件源为清华源
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
1
# 初始化时
- 修改
.jenkins目录中的hudson.model.UpdateCenter.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
2
3
4
5
6
7
2
3
4
5
6
7
- 修改
.jenkins/jenkins_home/updates/default.json文件 替换文件中所有以下关键字
https://updates.jenkins-ci.org/download修改为https://mirrors.tuna.tsinghua.edu.cn/jenkinshttps://updates.jenkins.io/download修改为https://mirrors.tuna.tsinghua.edu.cn/jenkinshttp://www.google.com修改为http://www.baidu.com
在浏览器中,
http://IP:8080/reload,这样可以重新载入配置。访问 http://localhost:8080/reload (opens new window) ,重启一下Jenkins ,选择安装推荐插件, 秒速安装成功,简直超速!!