RHEL系列是使用最广的Linux服务器系统之一,但是对于未付费用户,却无法通过Redhat网络安装和更新软件,这不能不说是一个遗憾。其实我们完全可以通过RHEL的同胞兄弟CentOS的源来更新,步骤如下:

1、在 /etc/yum.repos.d/ 目录下新建一个文件 CentOS-Base.repo

#vi CentOS-Base.repo

 

2、在该文件中录入以下内容并保存(本例的源在撰写本文时是有效的):

Linux配置代码  
  1. [base]   
  2. name=CentOS-5 – Base   
  3. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&   
  4. repo=os   
  5. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/   
  6. baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/   
  7. gpgcheck=1  
  8. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5   
  9.   
  10. #released updates   
  11. [update]   
  12. name=CentOS-5 – Updates   
  13. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates   
  14. baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/   
  15. gpgcheck=1  
  16. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5   
  17.   
  18. #packages used/produced in the build but not released   
  19. [addons]   
  20. name=CentOS-5 – Addons   
  21. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons   
  22.   
  23. baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/   
  24. gpgcheck=1  
  25. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5   
  26.   
  27. #additional packages that may be useful   
  28. [extras]   
  29. name=CentOS-5 – Extras   
  30. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras   
  31.   
  32. baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/   
  33. gpgcheck=1  
  34. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5   
  35.   
  36. #additional packages that extend functionality of existing packages   
  37. [centosplus]   
  38. name=CentOS-5 – Plus   
  39. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus   
  40. baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/   
  41. gpgcheck=1  
  42. enabled=0  
  43. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5   
  44.   
  45. #contrib – packages by Centos Users   
  46. [contrib]   
  47. name=CentOS-5 – Contrib   
  48. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib   
  49. baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/   
  50. gpgcheck=1  
  51. enabled=0  
  52. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5  
[base]name=CentOS-5 – Base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5#released updates[update]name=CentOS-5 – Updates#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updatesbaseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5#packages used/produced in the build but not released[addons]name=CentOS-5 – Addons#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addonsbaseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5#additional packages that may be useful[extras]name=CentOS-5 – Extras#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extrasbaseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5#additional packages that extend functionality of existing packages[centosplus]name=CentOS-5 – Plus#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplusbaseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5#contrib – packages by Centos Users[contrib]name=CentOS-5 – Contrib#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contribbaseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/gpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

 3、执行更新:

# yum update

 

======================================

另外,如果服务器需要通过代理上网,则需要设置一下代理服务器才能进行联网更新:

在 /etc/yum.conf文件加入下面一行内容,指定一下代理服务器参数:

 

#Set http proxy

proxy=http://192.168.1.100:8000