---
title: "yum安装与使用(转)"
author: "foolraty"
date: "2011-01-21T16:29:56Z"
tags: []
categories: ["操作系统"]
slug: "yum"
draft: false
lastmod: "2011-01-21T16:30:20Z"
id: 891020
url: "https://foolraty.iteye.com/blog/891020"
---

### 一些rpm的安装经验在: [http://foolraty.iteye.com/blog/890848](http://foolraty.iteye.com/blog/890848)

**第一种方法:**  
yum源来自chinalinuxpub.com,用的是centos包,  
下载地址: http://www.chinalinuxpub.com/yum.tgz  
安装:  
tar zxvf yum.tgz  
cd yum  
rpm -ivh \*.rpm

rm -rf /etc/yum.repos.d/CentOS-Base.repo  
vi /etc/yum.repos.d/as4-update.repo  
加入：  
#released updates  
\[update]  
name=Red Hat Enterprise AS release 4 Updates  
baseurl=http://ftp.chinalinuxpub.com/redhat/enterprise/updates/4AS/  
gpgcheck=1  
gpgkey=http://ftp.chinalinuxpub.com/redhat/enterprise/RPM-GPG-KEY-linuxpub

vi /etc/yum.repos.d/as4-base.repo  
加入：  
#released base  
\[base]  
name=Red Hat Enterprise AS release 4 Updates  
baseurl=http://ftp.chinalinuxpub.com/redhat/enterprise/os/i386/RedHat/ #在这个地方可以更改能连接上的网站  
gpgcheck=1  
gpgkey=http://ftp.chinalinuxpub.com/redhat/enterprise/RPM-GPG-KEY-linuxpub

然后就可以正常使用yum了.

使用:

yum localinstall \*.rpm

安装本地的包  
也可以 yum list|grep xxx.rpm xxx为想要安装的包   然后运行yum install xxx.rpm 就可以了

/var/cache/yum   是文件下载的地方   . 可以修改/etc/yum.conf 来改变文件夹的位置.

**第二种方法:**

利用CentOS 的yum库升级RHEL AS4

1.下载并安装yum-2.4.0-1.centos4.noarch.rpm文件，下载地址为：

[ftp://ftp.pbone.net/mirror/ftp.centos.org/4.2/os/alpha/CentOS/RPMS/yum-2.4.0-1.centos4.noarch.rpm](ftp://ftp.pbone.net/mirror/ftp.centos.org/4.2/os/alpha/CentOS/RPMS/yum-2.4.0-1.centos4.noarch.rpm)

[2.修改或建立/etc/yum.repos.d/CentOS-Base.repo为如下内容：  
\
\[base\]  
\
name=CentOS-$releasever - Base  
\
baseurl=http://ftp.riken.jp/Linux/caos/centos/4.0/os/$basearch/  
\
gpgcheck=1  
\
#released updates  
\
\[update\]  
\
name=CentOS-$releasever - Updates  
\
baseurl=http://ftp.riken.jp/Linux/caos/centos/4.0/updates/$basearch/  
\
gpgcheck=1  
\
#packages used/produced in the build but not released  
\
\[addons\]  
\
name=CentOS-$releasever - Addons  
\
baseurl=http://ftp.riken.jp/Linux/caos/centos/4.0/addons/$basearch/  
\
gpgcheck=1  
\
#additional packages that may be useful  
\
\[extras\]  
\
name=CentOS-$releasever - Extras  
\
baseurl=http://ftp.riken.jp/Linux/caos/centos/4.0/extras/$basearch/  
\
gpgcheck=1  
\
3.修改或建立/etc/yum.repos.d/dag.repo为如下内容：  
\
\[dag\]  
\
name=Dag RPM Repository for RHEL4  
\
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el4/en/$basearch/dag/](ftp://ftp.pbone.net/mirror/ftp.centos.org/4.2/os/alpha/CentOS/RPMS/yum-2.4.0-1.centos4.noarch.rpm)

[**IXDBA.NET技术社区**](http://www.ixdba.net/)

enabled=1

gpgcheck=1

gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt

4.运行update:

yum update

5.升级：

yum upgrade

6.安装其它软件，例如：

yum install mplayer

 

**第三种方法**

http://linux.duke.edu/projects/yum/download/2.0/yum-2.0.7-1.noarch.rpm 下载,并安装yum安装后要注意的是一下三个文件  
/etc/cron.daily/yum.cron　#每日进行yum 及 其他软件包定时升级  
/etc/init.d/yum　　#yum服务  
/etc/yum.conf　 #yum配置文件

接下来修改/etc/yum.conf  
vi /etc/yum.conf

将  
\[base]  
name=Red Hat Linux $releasever - $basearch - Base  
baseurl=http://mirror.dulug.duke.edu/pub/yum-repository/redhat/$releasever/$basearch/

\[updates]  
name=Red Hat Linux $releasever - Updates  
baseurl=http://mirror.dulug.duke.edu/pub/yum -repository/redhat/updates/$releasever/

改为  
\[base]  
name=CentOS 4.4 for RHEL4 - Base  #随便取名字  
baseurl= http://mirror.be10.com/centos/4.4/os/i386/

\[updates]  
name=CentOS 4.4 for RHEL4 - Updates #随便取名字  
baseurl= http://mirror.be10.com/centos/4.4/updates/i386/

输入命令  
yum update