linux使用国内镜像源

来源:互联网 发布:nginx 子域名映射端口 编辑:程序博客网 时间:2024/05/21 02:35

yum的出现,解决了软件编译的麻烦,不然还得查看软件configure的帮助文件,从头看到尾,装个lnmp能把人累死!
linux自带的base yum源都是国外的镜像,速度比较慢。安装好linux的第一步就是要把更新源换成国内的,我下面的例子是把镜像源换成163的。

第一步:切换到yum源的目录下:

cd /etc/yum.repos.d/

第二步:查看yum源设置文件

ls
CentOS6-Base-163.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  epel-testing.repo      webtatic.repoCentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo    nginx.repo             webtatic-testing.repoCentOS-CR.repo         CentOS-Media.repo      epel.repo            webtatic-archive.repo

第三步:先备份,以防万一

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

第四步:使用wget下载repo配置文件

#163的源:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo#阿里云的源wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo#注意,这个地址根据你的系统来决定,我的是centos7 

查看地址:http://mirrors.163.com/
centos帮助文件 http://mirrors.163.com/.help/centos.html
阿里云帮助文件:http://mirrors.aliyun.com/help/centos

第五步:建立缓存

yum makecache

yum makecache就是把服务器的包信息下载到本地电脑缓存起来,配合yum -C search xxx使用,不用上网检索就能查找软件信息,速度奇快!

原创粉丝点击