[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源文件:linux
其鏡像文件地址更換爲:「baseurl=http://mirrors.163.com/centos/apache
注: 該過程當中使用的yum源須要事先下載。vim
安裝一個擴展源文件(epel-release)便可:centos
[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包。bash
命令: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
即,該命令的含義就是隻下載不安裝。
下載的包默認保存位置爲:curl
[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/(自定義目錄)ui
[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
注: 下載源碼包要到官方網站或可信任站點——安全!