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.x86_64 : Apache HTTP Server
httpd-devel.i686 : Development interfaces for the Apache HTTP server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
mod_dav_svn.x86_64 : Apache httpd module for Subversion server
mod_dnssd.x86_64 : 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.x86_64 0:5.3.3-23.el6_4 will be installed
-> Processing Dependency: php-common(x86-64) = 5.3.3-23.el6_4 for package: php-5.3.3-23.el6_4.x86_64
-> Processing Dependency: php-cli(x86-64) = 5.3.3-23.el6_4 for package: php-5.3.3-23.el6_4.x86_64
--> Package php-gd.x86_64 0:5.3.3-23.el6_4 will be installed
-> Processing Dependency: libXpm.so.4()(64bit) for package: php-gd-5.3.3-23.el6_4.x86_64
--> Package php-pdo.x86_64 0:5.3.3-23.el6_4 will be installed
--> Package php-pear.noarch 1:1.9.4-4.el6 will be installed
--> Package php-xml.x86_64 0:5.3.3-23.el6_4 will be installed
-> Running transaction check
--> Package libXpm.x86_64 0:3.5.10-2.el6 will be installed
--> Package php-cli.x86_64 0:5.3.3-23.el6_4 will be installed
--> Package php-common.x86_64 0:5.3.3-23.el6_4 will be installed
-> Finished Dependency Resolution
Dependencies Resolved
==================================================
Package Arch Version Repository Size
==================================================
Installing:
php x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 1.1 M
php-gd x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 106 k
php-pdo x86_64 5.3.3-23.el6_4 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 x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 103 k
Installing for dependencies:
libXpm x86_64 3.5.10-2.el6 rhui-REGION-rhel-server-releases 51 k
php-cli x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 2.2 M
php-common x86_64 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.x86_64.rpm | 51 kB 00:00
(2/8): php-5.3.3-23.el6_4.x86_64.rpm | 1.1 MB 00:00
(3/8): php-cli-5.3.3-23.el6_4.x86_64.rpm | 2.2 MB 00:00
(4/8): php-common-5.3.3-23.el6_4.x86_64.rpm | 524 kB 00:00
(5/8): php-gd-5.3.3-23.el6_4.x86_64.rpm | 106 kB 00:00
(6/8): php-pdo-5.3.3-23.el6_4.x86_64.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.el6_4.x86_64.rpm | 103 kB 00:00
via: <http://linoxide.com/linux-command/package-management-yum-redhat-linux/>
译者:[Linux-pdz](https://github.com/Linux-pdz) 校对:[jasminepeng](https://github.com/jasminepeng)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
发表回复