1. 打開網址,進入centos/目錄,找到最新版本號,我這里最新版本號為:7.2.1511
2. 進入最新版本號目錄,找到os目錄,並依次進入其子目錄,直到可以看到repodata/該目錄為止
3. 復制該頁面地址,加入[base]模塊中的baseurl中:
4. 重復2,3步驟,進入最新版本號目錄,分別找到updates目錄,extras目錄,並依次進入其子目錄,直到可以看到repodata/該目錄為止,分別復制相應頁面網址,替換相應模塊中的baseurl,最終效果如圖:(配置源文件只需要用到[base],[extras],[updates]這個3個模塊就夠了,其他可以刪掉)
[base]
name=CentOS-$releasever - Base
baseurl=http://ftp.sjtu.edu.cn/centos/7.2.1511/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=http://ftp.sjtu.edu.cn/centos/7.2.1511/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=http://ftp.sjtu.edu.cn/centos/7.2.1511/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
5. 保存並退出,輸入yum clean all 清除本機上yum的舊資料,然后執行yum update 更新yum
6. 至此,就可以愉快的使用yum來安裝軟件了