rpm(Redhat Package Manager)RPM软件包管理器,是以一种数据库记录的方式来将咱们所须要的套件安装到Linux主机的一套管理程序。rpm包是预先在Linux机器上编译好并打包好的文件,安装起来很是快捷。可是有一个缺点:安装环境必须与编译时的一致或至关;包与包之间存在着相互依赖的状况,安装或卸载包时须要先把依赖的包安装/卸载,若是依赖的包时系统所必须的,那就不能卸载这个包。html
yum命令是在Fedora和RedHat以及SUSE中基于rpm的软件包管理器,它可使系统管理人员交互和自动化地更细与管理RPM软件包,可以从指定的服务器自动下载RPM包而且安装,能够自动处理依赖性关系,而且一次安装全部依赖的软体包,无须繁琐地一次次下载、安装。node
Linux软件的源代码分发是指提供了该软件全部程序源代码的发布形式,须要用户本身编译成可执行的二进制码并进行安装。其优势是配置灵活,能够随意去掉或保留某些功能/模块,适应多种硬件/操做系统平台及编译环境;缺点是难度较大。linux
挂载系统安装盘镜像(挂载到一个空目录,此处/mnt/目录未使用,因此直接挂载到/mnt/目录下)git
[root@cham3~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda3 28G 1.3G 27G 5% / devtmpfs 483M 0 483M 0% /dev tmpfs 493M 0 493M 0% /dev/shm tmpfs 493M 6.8M 486M 2% /run tmpfs 493M 0 493M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 99M 0 99M 0% /run/user/0 [root@cham3~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 写保护,将以只读方式挂载 [root@cham3 mnt]# ls CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7 EFI images Packages RPM-GPG-KEY-CentOS-Testing-7 EULA isolinux repodata TRANS.TBL [root@cham3 Packages]# # ls yum-plugin-changelog-1.1.31-40.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm yum-plugin-tmprepo-1.1.31-40.el7.noarch.rpm yum-plugin-verify-1.1.31-40.el7.noarch.rpm yum-plugin-versionlock-1.1.31-40.el7.noarch.rpm …… (rpm包格式:包名、版本号、发布版本号、平台)
rpm包存放在Packages该文件下!github
语法: rpm [options] [参数]
Options:
-i:=install,安装
-v:可视化
-h:显示安装进度
在安装一个rpm包时经常使用附带选项:
--force:强制安装
--nodeps:=no dependent 无依赖安装(忽视与其余包之间的依赖关系)docker
说明: 安装有依赖关系的包时,能够先安装其所依赖的包再安装目标包(同时安装存在依赖关系的包),或者使用--force或--nodeps选项进行强行安装(不建议使用)。数据库
列出全部rpm包apache
语法: yum listvim
[root@cham3 Packages]# yum list Failed to set locale, defaulting to C Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.aliyun.com * updates: mirrors.tuna.tsinghua.edu.cn Installed Packages NetworkManager-libnm.x86_64 1:1.4.0-12.el7 @anaconda NetworkManager-team.x86_64 1:1.4.0-12.el7 @anaconda zsh.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包。centos
[root@cham3 Packages]# ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-fasttrack.repo CentOS-CR.repo CentOS-Media.repo CentOS-Vault.repo
[root@cham3 Packages]## cat /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # …… [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ……
说明: 该文件下有rpm包所在库base的镜像地址信息!
语法: yum search [关键词]
[root@cham3 Packages]# yum search vim 已加载插件:fastestmirror Loading 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 descriptions vim-X11.x86_64 : The VIM version of the vi editor for the X Window System vim-common.x86_64 : The common files needed by any version of the VIM editor vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements vim-filesystem.x86_64 : VIM filesystem layout vim-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 @anaconda protobuf-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表示过滤。
语法: yum grouplist
[root@cham3 Packages]# yum list |grep 'vim' vim-minimal.x86_64 2:7.4.160-1.el7 @anaconda protobuf-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 grouplist Failed to set locale, defaulting to C Loaded plugins: fastestmirror There 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.cn Available Environment Groups: Minimal Install Compute Node …… Available Groups: Compatibility Libraries Console Internet Tools …… Done
语法: yum install [-y] [包名]
说明: 若是不加‘-y’选项,则会以与用户交互的方式安装。首先是列出须要安装的rpm包,而后会问用户是否须要安装,输入‘y’则安装,输入‘n’则不安装,这样太麻烦,因此直接加上‘-y’选项,省略与用户之间的交互。
语法: yum groupinstall [-y] [包的组名]
若是不知道组名,可用yum grouplist查看(注:进行安装时只能用英文名)。
语法: yum remove [-y] [包名]
说明: ‘-y’选项同install的用法,须要注意的是,在使用该命令进行卸载时会将目标文件所依赖的全部包同时删除,因此要谨慎使用!
语法: yum update [-y] [包名]
说明: 若是不加包名,则会升级系统内全部包以及系统自己(慎用,通常只在刚安装完系统时使用)。
该命令的做用是经过已知命令名称来搜索其rpm包名。
用法:
[root@cham3 Packages]# yum provides "/*/vim" 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn base/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/vim 2: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/vim 2: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/vim 2: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/vim git-1.8.3.1-11.el7.x86_64 : Fast Version Control System 源 :base 匹配来源: 文件名 :/usr/share/doc/git-1.8.3.1/contrib/vim git-1.8.3.1-12.el7_4.x86_64 : Fast Version Control System 源 :updates 匹配来源: 文件名 :/usr/share/doc/git-1.8.3.1/contrib/vim 2:vim-common-7.4.160-2.el7.x86_64 : The common files needed by any version of the VIM editor 源 :base 匹配来源: 文件名 :/usr/share/vim 2:vim-enhanced-7.4.160-2.el7.x86_64 : A version of the VIM editor which includes recent enhancements 源 :base 匹配来源: 文件名 :/usr/bin/vim
说明: 由于该命令位置不肯定,因此进行搜索时使用‘*’(通配符)来表明其路径。
有时候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-7 EFI 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]# ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-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:///mnt enable=1 gpgcheck=0 ******* 此部份内容除baseurl目录根据我的实际操做更改外,其他内容固定。 [root@cham3 yum.repos.d]# yum clean all 清除系统原有缓存 已加载插件:fastestmirror 正在清理软件源: dvd Cleaning up everything Cleaning up list of fastest mirrors [root@cham3 yum.repos.d]# yum list …… Available Packages 还未安装的可安装rpm包的库都变成dvd ypserv.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文件,而后恢复原来的配置文件。
能够设置使yum保留已经下载的rpm包,供之后升级或从新安装时使用。
修改/etc/yum/conf便可:
[main] cachedir=/home/soft1/yumcache keepcache=1 debuglevel=2
cachedir是放置下载的包的地方,能够修改为本身想放置的位置。
keepcache为1时表示保存已经下载的rpm包。
yum安装或二进制包安装.
把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包。
准备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
[base] name=CentOS-$releasever - Base baseurl=http://*.*.*.*/centos-6/ gpgcheck=1(改为0下面那行就不用设置了) gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6 enabled=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
文章原地址:http://www.linuxidc.com/Linux/2013-07/87315.htm
[root@cham3 yum.repos.d]# cd /etc/yum.repos.d [root@cham3 yum.repos.d]# ls dvd.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]# ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[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 Speed 100 1572 100 1572 0 0 17686 0 --:--:-- --:--:-- --:--:-- 17662 [root@cham3 yum.repos.d]# ls CentOS7-base-163.repo CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS7-Base-163.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo [root@cham3 yum.repos.d]# ls CentOS7-Base-163.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
说明: 执行完curl命令后,原有yum源文件CentOS-Base.repo被替换成CentOS7-Base-163.repo。查看该yum源文件:
其镜像文件地址更换为:“baseurl=http://mirrors.163.com/centos/
注: 该过程当中使用的yum源须要事先下载。
安装一个扩展源文件(epel-release)便可:
[root@cham3 yum.repos.d]# yum clean all 已加载插件:fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration 正在清理软件源: base extras updates Cleaning up everything Cleaning up list of fastest mirrors [root@cham3 yum.repos.d]# yum install wget 已加载插件:fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration base | 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 M Is this ok [y/d/N]: n Exiting on user command 您的事务已保存,请执行: yum load-transaction /tmp/yum_save_tx.2017-11-13.17-50.OIpKT3.yumtx 从新执行该事务 [root@cham3 yum.repos.d]# ls CentOS7-Base-163.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo [root@cham3 yum.repos.d]# yum install -y epel-release 已加载插件:fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading 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 k Downloading packages: epel-release-7-9.noarch.rpm | 14 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running 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]# ls CentOS7-Base-163.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo CentOS-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/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 ……
增长了不少来自epel库的rpm包。
命令:yum install -y [包名] --downloadonly
[root@cham3 yum.repos.d]# yum install zsh --downloadonly 已加载插件:fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading 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 M Background 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/packages zsh-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/ 已加载插件:fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading 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 M Background downloading packages, then exiting: exiting because "Download Only" specified [root@cham3 yum.repos.d]# ls /tmp/ 1.txt ping 1.txt.bz2 systemd-private-5e7aac884de0454ba5ebd5bd9d00d313-vmtoolsd.service-uIAz6R 1.txt.gz systemd-private-8ec0e8c254d142359576e2a0e2bfe61a-vmtoolsd.service-LyBTUz 1.txt.xz systemd-private-a02183c10a59447b842c913b6dc422af-vmtoolsd.service-rIsyod 88.txt yum_save_tx.2017-11-13.17-33.m0bd_Z.yumtx cham yum_save_tx.2017-11-13.17-43.dn3y8u.yumtx
说明: 当下一个已经安装过的包时系统不会执行任何操做,此时可使用“reinstall”来下该包。
下载一个已经安装过的包:
[root@cham3 yum.repos.d]# yum reinstall -y vim-enhanced --downloadonly --downloaddir=/tmp/ 已加载插件:fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading 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 M Background 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-uIAz6R 1.txt.bz2 systemd-private-8ec0e8c254d142359576e2a0e2bfe61a-vmtoolsd.service-LyBTUz 1.txt.gz systemd-private-a02183c10a59447b842c913b6dc422af-vmtoolsd.service-rIsyod 1.txt.xz vim-enhanced-7.4.160-2.el7.x86_64.rpm 88.txt yum_save_tx.2017-11-13.17-33.m0bd_Z.yumtx cham yum_save_tx.2017-11-13.17-43.dn3y8u.yumtx cham1 yum_save_tx.2017-11-13.17-50.OIpKT3.yumtx chamlinux yum_save_tx.2017-11-13.20-17.M797gr.yumtx ch.log yum_save_tx.2017-11-13.20-28.vE5oCa.yumtx d6z yum_save_tx.2017-11-13.20-31.IAN7EJ.yumtx ping zsh-5.0.2-28.el7.x86_64.rpm
先下载一个源码包!
注: 从此全部源码包放到目录“/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]# ls httpd-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]# ls ABOUT_APACHE BuildBin.dsp configure.in httpd.mak LAYOUT Makefile.in os server acinclude.m4 buildconf docs httpd.spec libhttpd.dep Makefile.win README srclib Apache.dsw CHANGES emacs-style include libhttpd.dsp modules README.platforms support build config.layout httpd.dep INSTALL libhttpd.mak NOTICE README-win32.txt test BuildAll.dsp configure httpd.dsp InstallBin.dsp LICENSE NWGNUmakefile ROADMAP VERSIONING
安装Apache:
[root@cham3 httpd-2.2.34]# ./configure --prefix=/usr/local/apache2 checking for chosen layout... Apache checking for working mkdir -p... yes …… checking for chosen layout... apr checking for gcc... no checking 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
注: 下载源码包要到官方网站或可信任站点——安全!