CentOS下可以通过yum很方便快捷的安装所需的软件和库,如果yum的源不好,安装速度会非常慢,CentOS默认官方源似乎都是国外的,所以速度无法保证,我一直使用163的源,感觉速度不错。下面就说说如何修改yum的源。
1、进入存放源配置的文件夹
cd /etc/yum.repos.d
2、备份默认源
mv ./CentOS-Base.repo ./CentOS-Base.repo.backup
3、使用wget下载163的源
wget http://mirrors.163.com/.help/CentOS-Base-163.repo
4、把下载下来的文件CentOS-Base-163.repo设置为默认源
mv CentOS-Base-163.repo CentOS-Base.repo
通过上述操作就把默认源修改为163的了。当然上述的操作可以合并为如下:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS-Base-163.repo -O /etc/yum.repos.d/CentOS-Base.repo
5. 配置文件参考
[root@localhost yum.repos.d]# vi CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5