[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
注: 下载源码包要到官方网站或可信任站点——安全!