博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
7.1 安装软件包的三种方法 7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法 7.5 yum搭建本地仓库...
阅读量:7107 次
发布时间:2019-06-28

本文共 27544 字,大约阅读时间需要 91 分钟。

  hot3.png

7.1 安装软件包的三种方法

  • rpm工具

rpm(Redhat Package Manager)RPM软件包管理器,是以一种数据库记录的方式来将我们所需要的套件安装到Linux主机的一套管理程序。rpm包是预先在Linux机器上编译好并打包好的文件,安装起来非常快捷。但是有一个缺点:安装环境必须与编译时的一致或相当;包与包之间存在着相互依赖的情况,安装或卸载包时需要先把依赖的包安装/卸载,如果依赖的包时系统所必须的,那就不能卸载这个包。

  • yum工具

yum命令是在Fedora和RedHat以及SUSE中基于rpm的软件包管理器,它可以使系统管理人员交互和自动化地更细与管理RPM软件包,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。

  • 源码包

Linux软件的源代码分发是指提供了该软件所有程序源代码的发布形式,需要用户自己编译成可执行的二进制码并进行安装。其优点是配置灵活,可以随意去掉或保留某些功能/模块,适应多种硬件/操作系统平台及编译环境;缺点是难度较大。

7.2-7.3 rpm工具

rpm包介绍(准备工作)

挂载系统安装盘镜像(挂载到一个空目录,此处/mnt/目录未使用,所以直接挂载到/mnt/目录下)

[root@cham3~]# df -h文件系统        容量  已用  可用 已用% 挂载点/dev/sda3        28G  1.3G   27G    5% /devtmpfs        483M     0  483M    0% /devtmpfs           493M     0  493M    0% /dev/shmtmpfs           493M  6.8M  486M    2% /runtmpfs           493M     0  493M    0% /sys/fs/cgroup/dev/sda1       197M  109M   88M   56% /boottmpfs            99M     0   99M    0% /run/user/0[root@cham3~]# mount /dev/cdrom /mnt/mount: /dev/sr0 写保护,将以只读方式挂载[root@cham3 mnt]# lsCentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7EULA             isolinux  repodata  TRANS.TBL[root@cham3 Packages]# # lsyum-plugin-changelog-1.1.31-40.el7.noarch.rpmyum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpmyum-plugin-tmprepo-1.1.31-40.el7.noarch.rpmyum-plugin-verify-1.1.31-40.el7.noarch.rpmyum-plugin-versionlock-1.1.31-40.el7.noarch.rpm……(rpm包格式:包名、版本号、发布版本号、平台)

rpm包存放在Packages该文件下!

rpm工具用法

安装rpm包

语法: rpm [options] [参数]

Options:
-i:=install,安装
-v:可视化
-h:显示安装进度
在安装一个rpm包时常用附带选项:
--force:强制安装
--nodeps:=no dependent 无依赖安装(忽视与其他包之间的依赖关系)

说明: 安装有依赖关系的包时,可以先安装其所依赖的包再安装目标包(同时安装存在依赖关系的包),或者使用--force或--nodeps选项进行强行安装(不建议使用)。

 

 

 

7.4 yum工具用法

 

列出所有rpm包

语法: yum list

[root@cham3 Packages]# yum list Failed to set locale, defaulting to CLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.aliyun.com * updates: mirrors.tuna.tsinghua.edu.cnInstalled PackagesNetworkManager-libnm.x86_64                1:1.4.0-12.el7              @anacondaNetworkManager-team.x86_64                 1:1.4.0-12.el7              @anacondazsh.x86_64                                        5.0.2-25.el7_3.1                    updates  zsh-html.x86_64                                   5.0.2-25.el7_3.1                    updates  zziplib.i686                                      0.13.62-5.el7                       base     zziplib.x86_64                                    0.13.62-5.el7                       base   ……Exiting on Broken Pipe注: 第一列是包名,第二列是版本号,第三列是库

说明: 库所在位置有“@”表示已安装;“updates”表示已安装,有新版本,需要升级;其他的表示可安装但还未安装的rpm包。

  • yum配置文件
[root@cham3 Packages]# ls /etc/yum.repos.d/CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-fasttrack.repoCentOS-CR.repo    CentOS-Media.repo      CentOS-Vault.repo
  • 配置文件base的信息
[root@cham3 Packages]## cat /etc/yum.repos.d/CentOS-Base.repo# CentOS-Base.repo#……[base]name=CentOS-$releasever - Basemirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7……

说明: 该文件下有rpm包所在库base的镜像地址信息!

搜索rpm包

语法: yum search [关键词]

[root@cham3 Packages]# yum search vim已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn=================================================== N/S matched: vim ===================================================protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptionsvim-X11.x86_64 : The VIM version of the vi editor for the X Window Systemvim-common.x86_64 : The common files needed by any version of the VIM editorvim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancementsvim-filesystem.x86_64 : VIM filesystem layoutvim-minimal.x86_64 : A minimal version of the VIM editor  名称和简介匹配 only,使用“search all”试试。

 说明: 使用该命令搜索时会列出所有包含‘vim’(关键词)的信息,不精确,为了只搜索相关rpm包,可用如下方法:

[root@cham3 Packages]# yum list |grep 'vim'vim-minimal.x86_64                          2:7.4.160-1.el7            @anacondaprotobuf-vim.x86_64                         2.5.0-8.el7                base     vim-X11.x86_64                              2:7.4.160-2.el7            base     vim-common.x86_64                           2:7.4.160-2.el7            base     vim-enhanced.x86_64                         2:7.4.160-2.el7            base     vim-filesystem.x86_64                       2:7.4.160-2.el7            base     vim-minimal.x86_64                          2:7.4.160-2.el7            base

说明: grep表示过滤。

 

列出rpm包组

语法: yum grouplist

[root@cham3 Packages]# yum list |grep 'vim'vim-minimal.x86_64                          2:7.4.160-1.el7            @anacondaprotobuf-vim.x86_64                         2.5.0-8.el7                base     vim-X11.x86_64                              2:7.4.160-2.el7            base     vim-common.x86_64                           2:7.4.160-2.el7            base     vim-enhanced.x86_64                         2:7.4.160-2.el7            base     vim-filesystem.x86_64                       2:7.4.160-2.el7            base     vim-minimal.x86_64                          2:7.4.160-2.el7            base     [root@cham3 Packages]# yum grouplist已加载插件:fastestmirror没有安装组信息文件Maybe run: yum groups mark convert (see man yum)Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn可用的环境分组:   最小安装   基础设施服务器   计算节点   文件及打印服务器   基本网页服务器   虚拟化主机   带 GUI 的服务器   GNOME 桌面   KDE Plasma Workspaces   开发及生成工作站可用组:   传统 UNIX 兼容性   兼容性程序库   图形管理工具   安全性工具   开发工具   控制台互联网工具   智能卡支持   科学记数法支持   系统管理   系统管理工具完成[root@cham3 Packages]#  yum grouplistFailed to set locale, defaulting to CLoaded plugins: fastestmirrorThere is no installed groups file.Maybe run: yum groups mark convert (see man yum)Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.aliyun.com * updates: mirrors.tuna.tsinghua.edu.cnAvailable Environment Groups:   Minimal Install   Compute Node……Available Groups:   Compatibility Libraries   Console Internet Tools……Done

安装rpm包

语法: yum install [-y] [包名]

说明: 如果不加‘-y’选项,则会以与用户交互的方式安装。首先是列出需要安装的rpm包,然后会问用户是否需要安装,输入‘y’则安装,输入‘n’则不安装,这样太麻烦,所以直接加上‘-y’选项,省略与用户之间的交互。

安装rpm包组

语法: yum groupinstall [-y] [包的组名]

如果不知道组名,可用yum grouplist查看(注:进行安装时只能用英文名)。

卸载rpm包

语法: yum remove [-y] [包名]

说明: ‘-y’选项同install的用法,需要注意的是,在使用该命令进行卸载时会将目标文件所依赖的所有包同时删除,所以要谨慎使用!

升级rpm包

语法: yum update [-y] [包名]

说明: 如果不加包名,则会升级系统内所有包以及系统本身(慎用,一般只在刚安装完系统时使用)。
 

yum provides

该命令的作用是通过已知命令名称来搜索其rpm包名。

用法:

[root@cham3 Packages]# yum provides "/*/vim"已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cnbase/7/x86_64/filelists_db                                                                       | 6.7 MB  00:00:08     extras/7/x86_64/filelists_db                                                                     | 486 kB  00:00:00     updates/7/x86_64/filelists_db                                                                    | 2.1 MB  00:00:03     cmake-2.8.12.2-2.el7.x86_64 : Cross-platform make system源    :base匹配来源:文件名    :/usr/share/cmake/editors/vim2:docker-unit-test-1.12.6-48.git0fdc778.el7.centos.x86_64 : Automates deployment of containerized applications - for                                                          : running unit tests源    :extras匹配来源:文件名    :/var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/runc-79c3939053c870fbb4de5484d98640d5ba028ef4/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim2:docker-unit-test-1.12.6-55.gitc4618fb.el7.centos.x86_64 : Automates deployment of containerized applications - for                                                          : running unit tests源    :extras匹配来源:文件名    :/var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/runc-31a9f6e22729606814e9bcbcf9eeebc1887527cb/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim2:docker-unit-test-1.12.6-61.git85d7426.el7.centos.x86_64 : Automates deployment of containerized applications - for                                                          : running unit tests源    :extras匹配来源:文件名    :/var/lib/docker-unit-test/runc-c5d311627d39439c5b1cc35c67a51c9c6ccda648/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim文件名    :/var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vimgit-1.8.3.1-11.el7.x86_64 : Fast Version Control System源    :base匹配来源:文件名    :/usr/share/doc/git-1.8.3.1/contrib/vimgit-1.8.3.1-12.el7_4.x86_64 : Fast Version Control System源    :updates匹配来源:文件名    :/usr/share/doc/git-1.8.3.1/contrib/vim2:vim-common-7.4.160-2.el7.x86_64 : The common files needed by any version of the VIM editor源    :base匹配来源:文件名    :/usr/share/vim2:vim-enhanced-7.4.160-2.el7.x86_64 : A version of the VIM editor which includes recent enhancements源    :base匹配来源:文件名    :/usr/bin/vim

说明: 因为该命令位置不确定,所以进行搜索时使用‘*’(通配符)来代表其路径。

7.5 yum搭建本地仓库

有时候Linux系统无法联网,此时无法使用网上的yum源,需要我们利用Linux系统光盘制作一个yum源。

步骤

挂载光盘——删除/etc/yum.repos.d/目录所有repo文件——创建新文件dvd.repo——清除原有缓存‘yum clean all’。

[root@cham3 Packages]# ls /mnt/CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL[root@cham3 Packages]# cd[root@cham3 ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bac[root@cham3 ~]# cd /etc/yum.repos.d                              切换目录[root@cham3 yum.repos.d]# lsCentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repoCentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo[root@cham3 yum.repos.d]# rm -rvf ./*     删除原有repo文件已删除"./CentOS-Base.repo"已删除"./CentOS-CR.repo"已删除"./CentOS-Debuginfo.repo"已删除"./CentOS-fasttrack.repo"已删除"./CentOS-Media.repo"已删除"./CentOS-Sources.repo"已删除"./CentOS-Vault.repo"[root@cham3 yum.repos.d]# vi dvd.repo*******[dvd]name=install dvd        baseurl=file:///mntenable=1gpgcheck=0*******此部分内容除baseurl目录根据个人实际操作更改外,其余内容固定。[root@cham3 yum.repos.d]# yum clean all清除系统原有缓存已加载插件:fastestmirror正在清理软件源: dvdCleaning up everythingCleaning up list of fastest mirrors[root@cham3 yum.repos.d]# yum list ……Available Packages  还未安装的可安装rpm包的库都变成dvdypserv.x86_64                                    2.31-8.el7                           dvd      yum-langpacks.noarch                             0.4.2-7.el7                          dvd      yum-plugin-aliases.noarch                        1.1.31-40.el7                        dvd      yum-plugin-changelog.noarch                      1.1.31-40.el7                        dvd      yum-plugin-tmprepo.noarch                        1.1.31-40.el7                        dvd      ……

配置完成后便可直接使用yum安装所需要的rpm包。如果不想使用本地yum源,需要删除/etc/yum.repos.d/dvd.repo文件,然后恢复原来的配置文件。

扩展1:yum保留已经安装过的包

可以设置使yum保留已经下载的rpm包,供以后升级或重新安装时使用。

修改/etc/yum/conf即可:

[main]cachedir=/home/soft1/yumcachekeepcache=1debuglevel=2

cachedir是放置下载的包的地方,可以修改成自己想放置的位置。

keepcache为1时表示保存已经下载的rpm包。

171247_72os_3708120.png

扩展2:yum局域网软件源搭建

搭建Apache服务器或ftp服务器

yum安装或二进制包安装.

准备RPM包

把CentOS的DVD1和DVD2.iso都下载下来,把DVD1.iso里的所有内容解压出来,放到/var/www/html/centos-6目录下,然后把DVD2.iso解压出来的Packages目录下的rpm包复制到/var/html/centos-6/Packages目录下,这样/var/html/centos-6/Packages里面就有了6000多个rpm包。

创建yum仓库

准备createrepo:yum -y install createrepo

创建repository:createrepo /var/www/html/centos-6/

创建完成之后,会在/var/www/html/centos-6/repodata下生成一些文件。

使用软件源

在其他centos机器上试试软件源能不能用。

  • 首先修改机器上软件源配置文件:
# cd /etc/yum.repos.d/# mkdir bk# mv *.repo bk/# cp bk/CentOS-Base.repo ./# vi CentOS-Base.repo
  • CentOS-Base.repo文件修改之后如下:
[base]name=CentOS-$releasever - Basebaseurl=http://*.*.*.*/centos-6/gpgcheck=1(改成0下面那行就不用设置了)gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6enabled=1#released updates #[updates]#name=CentOS-$releasever - Updates#baseurl=http:///*.*.*.*/centos-6/#gpgcheck=1#gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6#enabled = 1

保存之后,就可以使用局域网的软件源了:

# yum update

文章原地址:

7.6 yum更换国内源

  • 恢复系统默认yum源配置:
    [root@cham3 yum.repos.d]# cd /etc/yum.repos.d[root@cham3 yum.repos.d]# lsdvd.repo[root@cham3 yum.repos.d]# rm -f dvd.repo[root@cham3 yum.repos.d]# ls[root@cham3 yum.repos.d]# cp ../yum.repos.d.bak/* .[root@cham3 yum.repos.d]# lsCentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repoCentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo

     

  • 自定义yum源:
[root@cham3 yum.repos.d]# rm -fv CentOS-Bace.repo先删除默认yum源,然后使用wget命令建立新yum源:[root@cham3 yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-base-163.repo-bash: wget: 未找到命令此时wget命令未安装,同时删除了yum源文件,无法安装wget包。所以用下面的方法:“curl命令”[root@cham3 yum.repos.d]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed100  1572  100  1572    0     0  17686      0 --:--:-- --:--:-- --:--:-- 17662[root@cham3 yum.repos.d]# lsCentOS7-base-163.repo  CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repoCentOS7-Base-163.repo  CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo[root@cham3 yum.repos.d]# lsCentOS7-Base-163.repo  CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repoCentOS-Base.repo       CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo

说明: 执行完curl命令后,原有yum源文件CentOS-Base.repo被替换成CentOS7-Base-163.repo。查看该yum源文件:

其镜像文件地址更换为:“baseurl=

注: 该过程中使用的yum源需要事先下载。

 

7.7 yum下载rpm包

安装扩展源epel

安装一个扩展源文件(epel-release)即可:

[root@cham3 yum.repos.d]# yum clean all已加载插件:fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configuration正在清理软件源: base extras updatesCleaning up everythingCleaning up list of fastest mirrors[root@cham3 yum.repos.d]# yum install wget已加载插件:fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationbase                                                                                             | 3.6 kB  00:00:00     extras                                                                                           | 3.4 kB  00:00:00     updates                                                                                          | 3.4 kB  00:00:00     (1/4): base/7/x86_64/group_gz                                                                    | 156 kB  00:00:00     (2/4): extras/7/x86_64/primary_db                                                                | 129 kB  00:00:00     (3/4): updates/7/x86_64/primary_db                                                               | 3.6 MB  00:00:03     (4/4): base/7/x86_64/primary_db                                                                  | 5.7 MB  00:02:45     Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.zju.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 wget.x86_64.0.1.14-15.el7_4.1 将被 安装--> 解决依赖关系完成依赖关系解决======================================================================================================================== Package                 架构                      版本                                源                          大小========================================================================================================================正在安装: wget                    x86_64                    1.14-15.el7_4.1                     updates                    547 k事务概要========================================================================================================================安装  1 软件包总下载量:547 k安装大小:2.0 MIs this ok [y/d/N]: nExiting on user command您的事务已保存,请执行: yum load-transaction /tmp/yum_save_tx.2017-11-13.17-50.OIpKT3.yumtx 重新执行该事务[root@cham3 yum.repos.d]# lsCentOS7-Base-163.repo  CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repoCentOS-Base.repo       CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo[root@cham3 yum.repos.d]# yum install -y epel-release已加载插件:fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.zju.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 epel-release.noarch.0.7-9 将被 安装--> 解决依赖关系完成依赖关系解决======================================================================================================================= Package                          架构                       版本                     源                          大小=======================================================================================================================正在安装: epel-release                     noarch                     7-9                      extras                      14 k事务概要=======================================================================================================================安装  1 软件包总下载量:14 k安装大小:24 kDownloading packages:epel-release-7-9.noarch.rpm                                                                     |  14 kB  00:00:00     Running transaction checkRunning transaction testTransaction test succeededRunning transaction  正在安装    : epel-release-7-9.noarch                                                                            1/1   验证中      : epel-release-7-9.noarch                                                                            1/1 已安装:  epel-release.noarch 0:7-9                                                                                            完毕![root@cham3 yum.repos.d]# lsCentOS7-Base-163.repo  CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  epel.repoCentOS-Base.repo       CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo    epel-testing.repo

安装完成后,yum.repos.d/下增加“epel.repo”、“epel-testing.repo”两个文件:

[root@cham3 yum.repos.d]# cat epel.repo[epel]name=Extra Packages for Enterprise Linux 7 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7……

增加了很多来自epel库的rpm包。

下载rpm包

下载

命令:yum install -y [包名] --downloadonly

[root@cham3 yum.repos.d]# yum install zsh --downloadonly已加载插件:fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirror01.idc.hinet.net * extras: mirrors.aliyun.com * updates: mirrors.zju.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 zsh.x86_64.0.5.0.2-28.el7 将被 安装--> 解决依赖关系完成依赖关系解决======================================================================================================================= Package                 架构                       版本                                源                        大小=======================================================================================================================正在安装: zsh                     x86_64                     5.0.2-28.el7                        base                     2.4 M事务概要=======================================================================================================================安装  1 软件包总下载量:2.4 M安装大小:5.6 MBackground downloading packages, then exiting:zsh-5.0.2-28.el7.x86_64.rpm                                                                     | 2.4 MB  00:00:01     exiting because "Download Only" specified[root@cham3 yum.repos.d]# rpm -q zsh未安装软件包 zsh

即,该命令的含义就是只下载不安装。

下载的包默认保存位置为:

[root@cham3 yum.repos.d]# ls /var/cache/yum/x86_64/7/updates/packageszsh-5.0.2-25.el7_3.1.x86_64.rpm

自定义下载目录

命令:yum install -y [包名] --downloadonly --downloaddir=/tmp/(自定义目录)

[root@cham3 yum.repos.d]# yum install zsh --downloadonly --downloaddir=/tmp/已加载插件:fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirror01.idc.hinet.net * extras: mirrors.aliyun.com * updates: mirrors.zju.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 zsh.x86_64.0.5.0.2-28.el7 将被 安装--> 解决依赖关系完成依赖关系解决======================================================================================================================= Package                 架构                       版本                                源                        大小=======================================================================================================================正在安装: zsh                     x86_64                     5.0.2-28.el7                        base                     2.4 M事务概要=======================================================================================================================安装  1 软件包总下载量:2.4 M安装大小:5.6 MBackground downloading packages, then exiting:exiting because "Download Only" specified[root@cham3 yum.repos.d]# ls /tmp/1.txt      ping1.txt.bz2  systemd-private-5e7aac884de0454ba5ebd5bd9d00d313-vmtoolsd.service-uIAz6R1.txt.gz   systemd-private-8ec0e8c254d142359576e2a0e2bfe61a-vmtoolsd.service-LyBTUz1.txt.xz   systemd-private-a02183c10a59447b842c913b6dc422af-vmtoolsd.service-rIsyod88.txt     yum_save_tx.2017-11-13.17-33.m0bd_Z.yumtxcham       yum_save_tx.2017-11-13.17-43.dn3y8u.yumtx

说明: 当下一个已经安装过的包时系统不会执行任何操作,此时可以使用“reinstall”来下该包。

下载一个已经安装过的包:

[root@cham3 yum.repos.d]# yum reinstall -y vim-enhanced  --downloadonly --downloaddir=/tmp/已加载插件:fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirror01.idc.hinet.net * extras: mirrors.aliyun.com * updates: mirrors.zju.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 vim-enhanced.x86_64.2.7.4.160-2.el7 将被 已重新安装--> 解决依赖关系完成依赖关系解决======================================================================================================================= Package                       架构                    版本                                源                     大小=======================================================================================================================重新安装: vim-enhanced                  x86_64                  2:7.4.160-2.el7                     base                  1.0 M事务概要=======================================================================================================================重新安装  1 软件包总下载量:1.0 M安装大小:2.2 MBackground downloading packages, then exiting:vim-enhanced-7.4.160-2.el7.x86_64.rpm                                                           | 1.0 MB  00:00:00     exiting because "Download Only" specified[root@cham3 yum.repos.d]# ls /tmp/1.txt      systemd-private-5e7aac884de0454ba5ebd5bd9d00d313-vmtoolsd.service-uIAz6R1.txt.bz2  systemd-private-8ec0e8c254d142359576e2a0e2bfe61a-vmtoolsd.service-LyBTUz1.txt.gz   systemd-private-a02183c10a59447b842c913b6dc422af-vmtoolsd.service-rIsyod1.txt.xz   vim-enhanced-7.4.160-2.el7.x86_64.rpm88.txt     yum_save_tx.2017-11-13.17-33.m0bd_Z.yumtxcham       yum_save_tx.2017-11-13.17-43.dn3y8u.yumtxcham1      yum_save_tx.2017-11-13.17-50.OIpKT3.yumtxchamlinux  yum_save_tx.2017-11-13.20-17.M797gr.yumtxch.log     yum_save_tx.2017-11-13.20-28.vE5oCa.yumtxd6z        yum_save_tx.2017-11-13.20-31.IAN7EJ.yumtxping       zsh-5.0.2-28.el7.x86_64.rpm

7.8-7.9 源码包安装

先下载一个源码包!

注: 今后所有源码包放到目录“/usr/local/src/”!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

[root@cham3 src]#  wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz  下载Apache!该地址来自于“阿铭码市”。下载完后解压该文件:[root@cham3 src]#  tar zxvf httpd-2.2.32.tar.gz[root@cham3 src]# lshttpd-2.2.32  httpd-2.2.32.tar.gz查看文件httpd-2.2.32的内容:[root@cham3 src]# cd httpd-2.2.34[root@cham3 httpd-2.2.34]# lsABOUT_APACHE  BuildBin.dsp   configure.in  httpd.mak       LAYOUT        Makefile.in    os                serveracinclude.m4  buildconf      docs          httpd.spec      libhttpd.dep  Makefile.win   README            srclibApache.dsw    CHANGES        emacs-style   include         libhttpd.dsp  modules        README.platforms  supportbuild         config.layout  httpd.dep     INSTALL         libhttpd.mak  NOTICE         README-win32.txt  testBuildAll.dsp  configure      httpd.dsp     InstallBin.dsp  LICENSE       NWGNUmakefile  ROADMAP           VERSIONING

 安装Apache:

[root@cham3 httpd-2.2.34]#  ./configure --prefix=/usr/local/apache2checking for chosen layout... Apachechecking for working mkdir -p... yes……checking for chosen layout... aprchecking for gcc... nochecking for cc... no当某命令运行结束后,使用"echo $?"检验其是否正确:[root@cham3 httpd-2.2.34]#  echo $?1当该值为0时表示上一条命令正确,如果值为1则错误。此处值为1,即上面命令错误,查看其安装过程发现“checking for gcc... no”——表示“gcc”编译器不存在,所以需要先安装gcc编译器:[root@cham3 httpd-2.2.34]#  yum install -y gcc…………完毕![root@cham3 httpd-2.2.34]# ./configure --prefix=/usr/local/apache2再次安装。[root@cham3 httpd-2.2.34]# echo $?0检测,正确。②[root@cham3 httpd-2.2.34]# make   编译!……[root@cham3 httpd-2.2.34]# echo $?0③[root@cham3 httpd-2.2.34]# make install……[root@cham3 httpd-2.2.34]# echo $?0每次命令执行完后用“echo $?”进行检测,确保其正确。安装完成!查看其安装目录的内容:[root@cham3 httpd-2.2.34]# ls /usr/local/apache2/bin  build  cgi-bin  conf  error  htdocs  icons  include  lib  logs  man  manual  modules

注: 下载源码包要到官方网站或可信任站点——安全!

转载于:https://my.oschina.net/u/3708120/blog/1573024

你可能感兴趣的文章
day58——Saltstack二次开发(二)
查看>>
各种算法
查看>>
asp.net文章内容分页方法
查看>>
NGUI 界面自适应
查看>>
一起学Django之Day01
查看>>
css垂直居中
查看>>
单元测试
查看>>
ASP.NET 开源 Blog 收集
查看>>
THIS关键字
查看>>
软件工程概论个人作业04(最大子数组)
查看>>
企业级 SpringBoot 教程 (二十)处理表单提交
查看>>
opencv +python 提取roi目标区域全部像素的值 得出上下限 均匀值
查看>>
Hbase
查看>>
Lua,github,nginx
查看>>
英文论文润色的问题
查看>>
java实现二维码生成及调用打印机打印
查看>>
oracle多行合并一行,且需排序
查看>>
【java IO File】统计项目代码总共多少行
查看>>
vmware12中安装MAC OS X 10.10
查看>>
placeholder样式
查看>>