YUM是RHEL系统中提供的一个安装,卸载和搜索软件包的工具。它能做的不仅仅是安装、卸载软件包,它能做的还有更多,下面我们将在本文中为你展示。
YUM可以自动安装软件包的依赖包,例如当你使用yum安装httpd时,它还会自动安装https apache server以及它依赖的软件包。通过rpm软件包安装时就没有这么方便咯(译注:就是不会自动处理软件包依赖问题咯!),你必须下载所有它依赖的软件包,然后依序安装它们。
yum工具从远端服务器上的软件仓库(通常由OS提供商提供)获取软件包的信息。一个软件仓库是能在特定架构上运行的一系列rpm软件包的集合。例如,对于32位和64位系统各有一个软件仓库,还有针对RHEL5以及RHEL6的软件仓库。你也可以建立一个本地仓库,配置你的yum让其从你的本地仓库里搜索安装软件包。在接下来的例子中,我将向你展示除了安装和卸载软件,yum还可以做的其它事情。为方便理解,我将在我的Amazon EC2 RHEL 6.4服务器上使用httpd软件包为例。
从软件仓库里搜索软件包
“`
yum search httpd
Loaded plugins: amazon-id, rhui-lb, security
==================== N/S Matched: httpd ==========
httpd.x8664 : Apache HTTP Server
httpd-devel.i686 : Development interfaces for the Apache HTTP server
httpd-devel.x8664 : Development interfaces for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x8664 : Tools for use with the Apache HTTP Server
moddavsvn.x8664 : Apache httpd module for Subversion server
moddnssd.x8664 : An Apache HTTPD module which adds Zeroconf support
“`
想获得详细的输出信息,可以使用下面的命令:
“`
yum provides httpd
Loaded plugins: amazon-id, rhui-lb, security
httpd-2.2.15-26.el6.x86_64 : Apache HTTP Server
Repo : rhui-REGION-rhel-server-releases
Matched from:
“`
yum provides httpd在软件仓库里搜索含有httpd的软件包。
提供所有软件组列表
“`
yum grouplist
“`
以上命令将为你显示已经安装的以及可用的软件组。你可以使用软件组安装选项来安装其中一个软件组。例如,我们将安装一个PHP Support的软件组。这个软件组内包含需要的PHP软件包。
“`
yum groupinstall PHP Support
Loaded plugins: amazon-id, downloadonly, rhui-lb, security
Setting up Group Process
Warning: Group Support does not exist.
Resolving Dependencies
-> Running transaction check
–> Package php.x8664 0:5.3.3-23.el64 will be installed
-> Processing Dependency: php-common(x86-64) = 5.3.3-23.el64 for package: php-5.3.3-23.el64.x8664
-> Processing Dependency: php-cli(x86-64) = 5.3.3-23.el64 for package: php-5.3.3-23.el64.x8664
–> Package php-gd.x8664 0:5.3.3-23.el64 will be installed
-> Processing Dependency: libXpm.so.4()(64bit) for package: php-gd-5.3.3-23.el64.x8664
–> Package php-pdo.x8664 0:5.3.3-23.el64 will be installed
–> Package php-pear.noarch 1:1.9.4-4.el6 will be installed
–> Package php-xml.x8664 0:5.3.3-23.el64 will be installed
-> Running transaction check
–> Package libXpm.x8664 0:3.5.10-2.el6 will be installed
–> Package php-cli.x8664 0:5.3.3-23.el64 will be installed
–> Package php-common.x8664 0:5.3.3-23.el6_4 will be installed
-> Finished Dependency Resolution
Dependencies Resolved
==================================================
Package Arch Version Repository Size
Installing:
php x8664 5.3.3-23.el64 rhui-REGION-rhel-server-releases 1.1 M
php-gd x8664 5.3.3-23.el64 rhui-REGION-rhel-server-releases 106 k
php-pdo x8664 5.3.3-23.el64 rhui-REGION-rhel-server-releases 75 k
php-pear noarch 1:1.9.4-4.el6 rhui-REGION-rhel-server-releases 393 k
php-xml x8664 5.3.3-23.el64 rhui-REGION-rhel-server-releases 103 k
Installing for dependencies:
libXpm x8664 3.5.10-2.el6 rhui-REGION-rhel-server-releases 51 k
php-cli x8664 5.3.3-23.el64 rhui-REGION-rhel-server-releases 2.2 M
php-common x8664 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 524 k
Transaction Summary
Install 8 Package(s)
Total download size: 4.5 M
Installed size: 16 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): libXpm-3.5.10-2.el6.x8664.rpm | 51 kB 00:00
(2/8): php-5.3.3-23.el64.x8664.rpm | 1.1 MB 00:00
(3/8): php-cli-5.3.3-23.el64.x8664.rpm | 2.2 MB 00:00
(4/8): php-common-5.3.3-23.el64.x8664.rpm | 524 kB 00:00
(5/8): php-gd-5.3.3-23.el64.x8664.rpm | 106 kB 00:00
(6/8): php-pdo-5.3.3-23.el64.x8664.rpm | 75 kB 00:00
(7/8): php-pear-1.9.4-4.el6.noarch.rpm | 393 kB 00:00
(8/8): php-xml-5.3.3-23.el64.x86_64.rpm | 103 kB 00:00
via: http://linoxide.com/linux-command/package-management-yum-redhat-linux/
译者:Linux-pdz 校对:jasminepeng
主题测试文章,只做测试使用。发布者:eason,转转请注明出处:https://aicodev.cn/2013/11/20/%e5%9c%a8%e7%ba%a2%e5%b8%bdlinux%e4%b8%ad%e4%bd%bf%e7%94%a8yum%e5%8c%85%e7%ae%a1%e7%90%86%e5%99%a8/