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
注: 下載源碼包要到官方網站或可信任站點——安全!