三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

如何在 CentOS 7 上设置和使用 Yum 存储库

三三 2022-04-29 2416 0条评论 Linux使用 CentOS7yum源

首页 / 正文

官方 CentOS 7 存储库有一个庞大的软件包列表,它几乎涵盖了服务器软件方面的所有基础,但有时我们需要一些官方存储库中没有的附加软件包。在这种情况下,我们可以简单地添加新的存储库来进一步扩展我们可用的包目录。让我们从教程开始。

步骤 1. 通过 SSH 登录

以 root 用户或具有 sudo 权限的帐户通过 SSH 登录到您的 CentOS 7 服务器:

ssh root@IP_Address -p Port_number

确保将“ IP_Address ”和“ Port_number ”替换为您服务器的IP 地址和SSH 端口。

步骤 2. 更新操作系统包并安装 yum-utils 包:
登录到服务器后,运行以下命令以确保所有已安装的软件包都是最新的:

yum clean all
yum update

使用以下命令安装包:

yum-utils

我们可以在 CentOS 7 / RHEL 7 上启用 EPEL(企业 Linux 的额外软件包)存储库,该存储库由一个特殊的 Fedora 特别兴趣小组维护,该兴趣小组为企业 Linux 版本创建、维护和管理高质量的附加软件包。这包括 Red Hat Enterprise Linux (RHEL)、CentOS、Scientific Linux (SL) 和 Oracle Enterprise Linux (OEL)。

步骤 3. 安装 EPEL 存储库
要安装 EPEL rpm,请使用以下命令:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

输出将如下所示:

Retrieving https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-11                ################################# [100%]

检查新安装的存储库。您应该能够在列表中找到 EPEL 存储库。

yum repolist

您应该收到以下输出,或类似的输出:

base                                | 3.6 kB  00:00:00
epel/x86_64/metalink                |  11 kB  00:00:00
epel                                | 3.2 kB  00:00:00
extras                              | 3.4 kB  00:00:00
updates                             | 3.4 kB  00:00:00
(1/7): base/7/x86_64/group_gz       | 166 kB  00:00:00
(2/7): base/7/x86_64/primary_db     | 5.9 MB  00:00:00
(3/7): epel/x86_64/group_gz         |  88 kB  00:00:00
(4/7): epel/x86_64/updateinfo       | 934 kB  00:00:00
(5/7): updates/7/x86_64/primary_db  | 6.0 MB  00:00:00
(6/7): extras/7/x86_64/primary_db   | 204 kB  00:00:00
(7/7): epel/x86_64/primary          | 3.6 MB  00:00:00
epel                                12739/12739
repo id             repo name                  status
base/7/x86_64       CentOS-7 - Base            9,901+10
epel/x86_64         Extra Packages for Enterprise Linux 7 - x86_64                 12,739
extras/7/x86_64     CentOS-7 - Extras          432
updates/7/x86_64    CentOS-7 - Updates         1,543+71
repolist: 24,615

要查看 EPEL 存储库中可用的所有软件包,请运行以下命令:

yum --enablerepo=epel list | less

此命令的输出将显示包列表。

注意:其他可能有用的 CentOS 存储库位于/etc/yum.repos.d目录中。通过编辑 .repo 文件手动启用某些存储库时,请确保在 repo 文件中使用 CentOS 的主版本,在这种情况下,它是 CentOS 7。

例如,编辑 CentOS-Base.repo 文件并添加/修改这些行:

[base]
name=CentOS $releasever – Base
baseurl=http://mirror.centos.org/centos/7/os/$basearch/
gpgcheck=0
enabled=1

[updates]
name=CentOS $releasever – Updates
baseurl=http://mirror.centos.org/centos/7/updates/$basearch/
gpgcheck=0
enabled=1

[extras]
name=CentOS $releasever – Extras
baseurl=http://mirror.centos.org/centos/7/extras/$basearch/
gpgcheck=0
enabled=1

列出所有存储库
要列出所有存储库,包括所有启用和禁用的存储库,请运行:

yum repolist all

启用 Yum 存储库
要启用 Yum 存储库,请以 root 身份运行以下命令:

yum-config-manager --enable repository <repository name>

禁用 Yum 存储库
要禁用 Yum 存储库,请以 root 身份运行以下命令:

yum-config-manager --disable repository <repository name>

不要忘记将 <repository name>替换为实际的 repo 名称。

如果由于某种原因我们在官方和 EPEL 软件库中找不到我们需要的软件包,我们可以通过添加额外的软件库来扩展服务器的功能,例如 Remi RPM 软件库,它不是 CentOS 的官方软件库分发,但维护良好,始终保持最新。

Remi Collet 维护着大量的 RPM 软件包,包括最新版本的 PHP 等。请注意,这个 repo 并不总是能很好地与其他第三方 CentOS repos 配合使用,因此请检查使用的 repositories 列表, yum repolist如果有,请禁用其他 repositories任何包冲突。

我们可以使用以下命令安装 Remi 存储库:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

例如,如果我们想要启用 PHP 7.2 ,我们可以编辑/etc/yum.repos.d/remi-php72.repo文件并将 enabled=0 更改为 enabled=1

# This repository only provides PHP 7.2 and its extensions
# NOTICE: common dependencies are in "remi-safe"

[remi-php72]
name=Remi's PHP 7.2 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php72/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php72/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php72/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

另一个不错的非官方 CentOS 存储库是 Webtatic Repo。此存储库提供更新的包以及更高版本的 PHP、MySQL 和其他包。有了这些信息,您现在可以安装您选择的任何存储库,并以您需要的任何方式扩展服务器的功能。

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

文章目录

上一张 下一张