红联Linux门户
Linux帮助

在CentOS或者RHEL上安装REMI仓库

发布时间:2014-11-12 10:30:36来源:linux.cn作者:Linux中国

Question:我该如何在CentOS或者RHEL中配置REMI仓库,并安装其中的包?

REMI 仓库提供了CentOS和RHEL的核心包的更新版本,尤其是最新的PHP/MySQL系列(LCTT 译注:当你需要一个更新包,而 CentOS/RHEL 没有及时提供更新时, REMI 仓库可以帮助你)。

安装REMI仓库要记住的一件事是不要在启用了REMI仓库时运行yum update。因为REMI仓库的包名与RHEL/CentOS中的相同,运行yum update可能会触发意外的更新。一个好办法是禁用REMI仓库,在你需要安装RMEI仓库中独有的包时再启用。


预备工作

安装REMI仓库之前,你首先需要启用EPEL仓库,因为REMI中的一些包依赖于EPEL。按照这份指南在CentOS或者RHEL中设置EPEL仓库。


安装REMI仓库

现在按照下面的步骤安装REMI仓库。

在CentOS 7上:

$ sudo rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
$ sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

在CentOS 6上:

$ sudo rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
$ sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

默认地,REMI是禁用的。要检查REMI是否已经成功安装,使用这个命令。你会看到几个REMI仓库,比如remi、remi-php55和remi-php56。

$ yum repolist disabled | grep remi


从REMI仓库中安装一个包

如上所述,最好保持禁用REMI仓库,只有在需要的时候再启用。

要搜索或安装REMI仓库中的包,使用这些命令:

$ sudo yum --enablerepo=remi search <keyword>
$ sudo yum --enablerepo=remi install <package-name>


How to set up EPEL repository on CentOS

If you are using CentOS or RHEL, it is strongly recommended that you configure EPEL (Extra Packages for Enterprise Linux) repository on your system. EPEL is a community effort to create a repository of high-quality add-on free software packages for RHEL-based distributions. Once you set up EPEL repository, you can use yum command to install any of close to 7,000 EPEL packages.

In order to enable EPEL repository on your CentOS system, you need to check CentOS version. To do that, run the following command.
$ cat /etc/RedHat-release

CentOS release 6.3 (Final)

Then install a corresponding EPEL release RPM package as follows. Note that the EPEL release RPM does not depend on the underlying processor architecture (e.g., 32-bit/64-bit x86, ppc, sparc, alpha, etc), so no need to pay attention to processor architecture difference.
Set up EPEL on CentOS 7

Starting from CentOS 7, EPEL release RPM package is available in "extras" repo. Therefore, simply use yum command to set up EPEL repository on these platforms:
$ sudo yum install epel-release
Set up EPEL on CentOS 6 or Earlier

For earlier versions of CentOS, you can use rpm command to download and install a RPM file manually as follows.

For CentOS/RHEL 6.*:
$ sudo rpm -Uvh http://mirrors.kernel.org/Fedora-epel/6/i386/epel-release-6-8.noarch.rpm

For CentOS/RHEL 5.*:
$ sudo rpm -Uvh http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm

During installation, you may see the following warning, which indicates that EPEL's GPG key is missing.

warning: /var/tmp/rpm-tmp.3TKM2G: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY

The EPEL's official GPG key is found in /etc/pki/rpm-gpg. Go ahead and import the GPG key as follows.
$ sudo sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 (for CentOS 6)
$ sudo sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 (for CentOS 7)

To verify that EPEL repository has been set up successfully, run the following command to list all available repositories on your system.
$ yum repolist