首页 > 网站 > 帮助中心 > 正文

CentOS 6编译安装yum和配置常用的yum源

2024-07-09 22:49:12
字体:
来源:转载
供稿:网友

安装环境:VPS,CentOS 6 + devel

 

一、安装相应的软件

1.安装python

下载Python源码包

[root@akinlau ~]# wget http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tar.bz2

解压Python源码包

[root@akinlau ~]# tar jxvf Python-2.4.3.tar.bz2

编译安装Python

[root@akinlau ~]# cd Python-2.4.3

[root@akinlau Python-2.4.3]# ./configure

checking MACHDEP... linux2

checking EXTRAPLATDIR...

checking for --without-gcc... no

checking for --with-cxx=<compiler>... no

checking for c++... c++

 

checking for /dev/ptmx... yes

checking for /dev/ptc... no

checking for socklen_t... yes

checking for build directories... done

configure: creating ./config.status

config.status: creating Makefile.pre

config.status: creating Modules/Setup.config

config.status: creating pyconfig.h

creating Setup

creating Setup.local

creating Makefile

 

[root@akinlau Python-2.4.3]# make

[root@akinlau Python-2.4.3]# make install

running install_scripts

copying build/scripts-2.4/smtpd.py -> /usr/local/bin

copying build/scripts-2.4/pydoc -> /usr/local/bin

copying build/scripts-2.4/idle -> /usr/local/bin

changing mode of /usr/local/bin/smtpd.py to 755

changing mode of /usr/local/bin/pydoc to 755

changing mode of /usr/local/bin/idle to 755

if test -f /usr/local/bin/python -o -h /usr/local/bin/python;

       then rm -f /usr/local/bin/python;

       else true;

       fi

(cd /usr/local/bin; ln python2.4 python)

Creating directory /usr/local/man

Creating directory /usr/local/man/man1

/usr/bin/install -c -m 644 ./Misc/python.man

              /usr/local/man/man1/python.1

2.下载并安装python-urlgrabberpython-pycurlyum-metadata-parser

[root@akinlau ~] wget http://tel.mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-8.el6.noarch.rpm

[root@akinlau ~] wget http://tel.mirrors.163.com/centos/6/os/x86_64/Packages/python-pycurl-7.19.0-8.el6.x86_64.rpm

[root@akinlau ~] wget http://tel.mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

[root@akinlau ~] rpm -ivh python-urlgrabber-3.9.1-8.el6.noarch.rpm python-pycurl-7.19.0-8.el6.x86_64.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

3.创建yum配置文件

[root@akinlau ~] touch /etc/yum.conf

4.下载yum源码包并安装

[root@akinlau ~] wget http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz

解压源码包
[root@akinlau ~] tar zxvf yum-3.4.3.tar.gz

编译安装yum
[root@akinlau ~] cd yum-3.4.3

[root@akinlau yum-3.4.3] ./yummain.py install yum

base                                                         | 3.7 kB     00:00    

base/primary_db                                              | 4.5 MB     00:07    

extras                                                       | 3.5 kB     00:00    

extras/primary_db                                            |  23 kB     00:03

出现以上提示就证明yum已经安装成功了。

 

二、配置yum(建议使用国内的163sohu源,速度比较快)

1.网易(163) yum

下载对应版本repo文件放入/etc/yum.repos.d/(操作前请做好相应备份)

CentOS5

wget http://mirrors.163.com/.help/CentOS5-Base-163.repo

CentOS6

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

运行yum makecache生成缓存

2.搜狐(sohu) yum 

下载CentOS-Base-sohu.repo, 放入/etc/yum.repos.d/

wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

运行yum makecache生成缓存

3.EPEL

下载相应的RPM包安装

6版企业版 Linux

wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm

5版企业版 Linux

wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

4.RPMForge

下载对应系统版本的RPM包安装

EL 6:

i686:

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

x86_64:

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

EL 5:

i386:

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

x86_64:

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

163sohu的源直接下载相应的repo文件放到/etc/yum.repos.d/目录,然后运行yum makecache生成缓存就可以使用

 

EPEL源和RPMForge源(国外的yum源)都是下载相应的RPM包安装后会自动在/etc/yum.repos.d/目录下生成相应的repo文件,然后运行yum makecache生成缓存就可以使用

不建议多种源一起用,一般情况下一个官方标准源加一个上面的其中一个源就足够用了,以上源对CentOS等系统完全兼容,但各软件库之间并不能保证完全兼容没有冲突。如果您需要同时使用以上源,您需要安装yum-priorities插件。安装yum-priorities插件后,您可以给各个源设置优先级priority。一般设置官方标准源优先级为1,最高,第三方源推荐>10priority=N N199的正整数,数值越小越优先)。如果不想使用某个源的话可以在repo文件中设置 enabled=0不启用该源,如果想启用设成enabled=1就可以了。

 

下面以官方标准源:CentOS-Base.repo为例子,说明一下主要的设置选项:

[base]                   //软件源的名称,将被yum取得并识别

name=CentOS-$releasever - Base  //定义软件仓库的名称,没实际作用

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

//mirrorlist指定镜像服务器的地址列表

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

//baseurl指定一个源的镜像服务器地址,这里加了#表示注释了yum将忽略这一行

priority=1            //设置源优先级,199的正整数,数值越小越优先

enabled=0             //这个选项表示是否启用repo中定义的这个源,0为禁用,1为启用

gpgcheck=1          //这个选项表示是否要对下载的rpm包进行gpg的校验,来确定rpm包的来源是有效和安全的,跟下面的gpgkey成对使用

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6          //定义用于校验的gpg密钥

 

 

关键字:VPS,YUM安装,YUM源配置

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表