更换yum仓库源
- cd /etc/yum.repos.d/
- rm -f dvd.repo
- wget 或者
- curl -O
- yum list
- 删除之前我们设置的本地源dvd.repo
[root@linux-128 yum.repos.d]# rm dvd.reporm:是否删除普通文件 "dvd.repo"?y
- 将之前备份的文件拷贝到yum.repos下
[root@linux-128 yum.repos.d]# cp -r /etc/yum.repos.d.bak/* ./[root@linux-128 yum.repos.d]# lsCentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
- CentOS-Base.repo 这个配置文件就是我们要设置的网络源,先将它备份一下。
[root@linux-128 yum.repos.d]# mv CentOS-Base.repo Centos-Base.repo.bak
- 下载一个163的yum源,因为之前将CentOS-Base.repo重命名了,使用wget下载需要安装wget包,但是我们这个时候yum是没办法安装wget包的,所以可以curl –O 来下载:
[root@linux-128 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 7651 0 --:--:-- --:--:-- --:--:-- 7820[root@linux-128 yum.repos.d]# lsCentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Sources.repoCentOS-Base.repo.bak CentOS-fasttrack.repo CentOS-Vault.repoCentOS-CR.repo CentOS-Media.repo
- 编辑看下配置文件
[root@linux-128 yum.repos.d]# vim CentOS7-Base-163.repo
- 清理之前本地yum缓存
[root@linux-128 yum.repos.d]# yum clean all已加载插件:fastestmirror正在清理软件源: base extras updatesCleaning up everythingCleaning up list of fastest mirrors
- 安装zsh包
[root@linux-128 yum.repos.d]# yum install -y zsh已加载插件:fastestmirrorLoading mirror speeds from cached hostfile正在解决依赖关系--> 正在检查事务---> 软件包 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 MDownloading packages:zsh-5.0.2-28.el7.x86_64.rpm | 2.4 MB 00:00:02Running transaction checkRunning transaction testTransaction test succeededRunning transaction 正在安装 : zsh-5.0.2-28.el7.x86_64 1/1 验证中 : zsh-5.0.2-28.el7.x86_64 1/1已安装: zsh.x86_64 0:5.0.2-28.el7完毕!
- yum list //生成yum缓存
安装扩展源epel
- yum install -y epel-release
- yum list |grep epel
[root@linux-128 yum.repos.d]# yum list |grep epel|head -15 * epel: ftp.cuhk.edu.hkepel-release.noarch 7-9 @extras0ad.x86_64 0.0.22-1.el7 epel0ad-data.noarch 0.0.22-1.el7 epel0install.x86_64 2.11-1.el7 epel2048-cli.x86_64 0.9.1-1.el7 epel2048-cli-nocurses.x86_64 0.9.1-1.el7 epel2ping.noarch 3.2.1-2.el7 epel389-admin.x86_64 1.1.46-1.el7 epel389-admin-console.noarch 1.1.12-1.el7 epel389-admin-console-doc.noarch 1.1.12-1.el7 epel389-adminutil.x86_64 1.1.21-2.el7 epel389-adminutil-devel.x86_64 1.1.21-2.el7 epel389-console.noarch 1.1.18-1.el7 epel389-ds.noarch 1.2.2-6.el7 epel
yum下载rpm包
- yum install -y 包名 --downloadonly
- ls /var/cache/yum/x86_64/7/
- yum install -y 包名 --downloadonly --downloaddir=路径
- yum reinstall -y 包名 --downloadonly --downloaddir=路径
有时候我们需要下载rpm包,而仅仅是复制给其他机器使用,yum工具安装rpm包时,首先下载这个rpm包,然后再去安装,所以我们可以做到只下载而不安装。
1. 下载rpm包而不安装的命令如下:# yum install -y 2ping.noarch --downloadonly
[root@linux-128 yum.repos.d]# yum install -y 2ping.noarch --downloadonly已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * epel: ftp.cuhk.edu.hk正在解决依赖关系--> 正在检查事务---> 软件包 2ping.noarch.0.3.2.1-2.el7 将被 安装--> 解决依赖关系完成依赖关系解决================================================================================= Package 架构 版本 源 大小=================================================================================正在安装: 2ping noarch 3.2.1-2.el7 epel 62 k事务概要=================================================================================安装 1 软件包总下载量:62 k安装大小:204 kBackground downloading packages, then exiting:警告:/var/cache/yum/x86_64/7/epel/packages/2ping-3.2.1-2.el7.noarch.rpm.2289.tmp: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY2ping-3.2.1-2.el7.noarch.rpm.2289.tmp 的公钥尚未安装2ping-3.2.1-2.el7.noarch.rpm | 62 kB 00:00:01exiting because "Download Only" specified
yum默认下载到/var/cache/yum/x86_64/7/XXX/packages/ 下面;这里的XXX指的是base,updates,epel等,它跟yum list最右侧的字符串一致。
[root@linux-128 yum.repos.d]# ls /var/cache/yum/x86_64/7/epel/packages/2ping-3.2.1-2.el7.noarch.rpm zmap-2.1.1-1.el7.x86_64.rpmhiredis-0.12.1-1.el7.x86_64.rpm
2. 下载到指定的目录下:--downloaddir=目录
[root@linux-128 yum.repos.d]# yum install -y zmap --downloadonly --downloaddir=/tmp/已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * epel: ftp.cuhk.edu.hk正在解决依赖关系--> 正在检查事务---> 软件包 zmap.x86_64.0.2.1.1-1.el7 将被 安装--> 正在处理依赖关系 libhiredis.so.0.12()(64bit),它被软件包 zmap-2.1.1-1.el7.x86_64 需要--> 正在检查事务---> 软件包 hiredis.x86_64.0.0.12.1-1.el7 将被 安装--> 解决依赖关系完成依赖关系解决================================================================================================ Package 架构 版本 源 大小================================================================================================正在安装: zmap x86_64 2.1.1-1.el7 epel 124 k为依赖而安装: hiredis x86_64 0.12.1-1.el7 epel 29 k事务概要================================================================================================安装 1 软件包 (+1 依赖软件包)总下载量:154 k安装大小:378 kBackground downloading packages, then exiting:exiting because "Download Only" specified[root@linux-128 yum.repos.d]# ls /tmp1.txt.bz21.txt.gz1.txt.xz222hiredis-0.12.1-1.el7.x86_64.rpmsystemd-private-7d28b5738df345b0bb18e85cef932021-vmtoolsd.service-43orfAtestyum_save_tx.2017-11-14.23-50.Av9TET.yumtxyum_save_tx.2017-11-14.23-50.ClMWHy.yumtxyum_save_tx.2017-11-14.23-56.v0Q9N8.yumtxzmap-2.1.1-1.el7.x86_64.rpm
如果已经安装过的包使用—downloadnoly就不起作用了,他会提示这个包已经安装过了,根本下载不下来:
[root@linux-128 yum.repos.d]# yum install -y tree --downloadonly --downloaddir=/tmp/已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * epel: ftp.cuhk.edu.hk软件包 tree-1.6.0-10.el7.x86_64 已安装并且是最新版本无须任何处理
3. 如果就是想下载已经安装过过的RPM包,使用命令reinstall
[root@linux-128 yum.repos.d]# yum reinstall -y tree --downloadonly --downloaddir=/tmp/已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * epel: ftp.cuhk.edu.hk正在解决依赖关系--> 正在检查事务---> 软件包 tree.x86_64.0.1.6.0-10.el7 将被 已重新安装--> 解决依赖关系完成依赖关系解决================================================================================================ Package 架构 版本 源 大小================================================================================================重新安装: tree x86_64 1.6.0-10.el7 base 46 k事务概要================================================================================================重新安装 1 软件包总下载量:46 k安装大小:87 kBackground downloading packages, then exiting:tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00exiting because "Download Only" specified[root@linux-128 yum.repos.d]# ls /tmp/1.txt.bz21.txt.gz1.txt.xz222hiredis-0.12.1-1.el7.x86_64.rpmsystemd-private-7d28b5738df345b0bb18e85cef932021-vmtoolsd.service-43orfAtesttree-1.6.0-10.el7.x86_64.rpm
源码包安装
- cd /usr/local/src/
- wget
- tar zxvf httpd-2.2.32.tar.gz
- cd httpd-2.2.32
- ./configure --prefix=/usr/local/apache2
- make
- make install
- 卸载就是删除安装的文件
解包后,我们开始安装前要查看 INSTALL ;REDME 两个安装指导文件,查看怎么安装, 安装源码包通常有3个步骤:
./configure //这一步可以定制功能,./configure --prefix=/usr/local/apache2 定义安装目录 make //编译成电脑识别的二进制文件 make install //用于创建相关软件的存放目录和配置文件- 下载源码包
[root@linux-128 yum.repos.d]# cd /usr/local/src/[root@linux-128 src]# wget https://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz--2017-11-15 00:26:41-- https://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz正在解析主机 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.177, 2402:f000:1:416:101:6:6:177正在连接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.177|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:7684419 (7.3M) [application/octet-stream]正在保存至: “httpd-2.2.34.tar.gz”100%[======================================================>] 7,684,419 1.20MB/s 用时 7.3s2017-11-15 00:26:49 (1.00 MB/s) - 已保存 “httpd-2.2.34.tar.gz” [7684419/7684419])[root@linux-128 src]# lshttpd-2.2.34.tar.gz
注意:将源码包移动到/usr/local/src 下;约定,将源码包都放在这个文件下
- 解包
[root@linux-128 httpd-2.2.34]# tar -zxvf httpd-2.2.34.tar.gz[root@linux-128 src]# lshttpd-2.2.34 httpd-2.2.34.tar.gz[root@linux-128 src]# cd httpd-2.2.34[root@linux-128 httpd-2.2.34]# lsABOUT_APACHE CHANGES httpd.dsp libhttpd.dep NOTICE serveracinclude.m4 config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclibApache.dsw configure httpd.spec libhttpd.mak os supportbuild configure.in include LICENSE README testBuildAll.dsp docs INSTALL Makefile.in README.platforms VERSIONINGBuildBin.dsp emacs-style InstallBin.dsp Makefile.win README-win32.txtbuildconf httpd.dep LAYOUT modules ROADMAP
1 ./configure --prefix=/usr/local/apache2
[root@linux-128 httpd-2.2.34]# ./configure --prefix=/usr/local/apache2checking for chosen layout... Apachechecking for working mkdir -p... yeschecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuConfiguring Apache Portable Runtime library ...checking for APR... reconfigconfiguring package in srclib/apr nowchecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuConfiguring APR libraryPlatform: x86_64-unknown-linux-gnuchecking for working mkdir -p... yesAPR Version: 1.5.2checking for chosen layout... aprchecking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/usr/local/src/httpd-2.2.34/srclib/apr':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more detailsconfigure failed for srclib/apr
注意: checking for gcc... no;没有安装gcc编译器
[root@linux-128 httpd-2.2.34]# yum install -y gcc[root@linux-128 httpd-2.2.34]# ./configure --prefix=/usr/local/apache2
- 验证是否成功命令:echo $?,返回值0,说明没有问题。
[root@linux-128 httpd-2.2.34]# echo $?0
2 进行编译:make
[root@linux-128 httpd-2.2.34]# make
- 执行完后可以echo $? ,0表示正常
[root@linux-128 httpd-2.2.34]# echo $?0
3 安装:make install
[root@linux-128 httpd-2.2.34]# make install
- 执行完后可以echo $? ,0表示正常
[root@linux-128 httpd-2.2.34]# echo $?0
查看apache2目录
[root@linux-128 httpd-2.2.34]# ls /usr/local/apache2/bin build cgi-bin conf error htdocs icons include lib logs man manual modules