yum下载rpm包及源码包安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了yum下载rpm包及源码包安装相关的知识,希望对你有一定的参考价值。
7.6 yum更换国内源
恢复系统默认yum源配置:
[[email protected] Packages]# cd /etc/yum.repos.d[[email protected] yum.repos.d]# lsdvd.repo [[email protected] yum.repos.d]# rm -f dvd.repo[[email protected] yum.repos.d]# ls[[email protected] yum.repos.d]# cp ../yum.repos.d.bak/* .[[email protected] yum.repos.d]# lsCentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
自定义yum源:
[[email protected] yum.repos.d]# rm -f CentOS-Base.repo先删除默认yum源,然后使用wget命令建立新yum源: [[email protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo-bash: wget: 未找到命令 此时wget命令未安装,同时删除了yum源文件,无法安装wget包。 所以用下面的方法:“curl命令” [[email protected] 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 8959 0 --:--:-- --:--:-- --:--:-- 8982[[email protected] yum.repos.d]# lsCentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
说明: 执行完curl命令后,原有yum源文件CentOS-Base.repo被替换成CentOS7-Base-163.repo。查看该yum源文件:
[[email protected] yum.repos.d]# vim CentOS7-Base-163.repo## CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client. You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead.##[base] name=CentOS-$releasever - Base - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osbaseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#released updates[updates] name=CentOS-$releasever - Updates - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates "CentOS7-Base-163.repo" 41L, 1572C
其镜像文件地址更换为:“baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/”。
注: 该过程中使用的yum源需要事先下载。
Finished!
7.7 yum下载rpm包
安装扩展源epel
安装一个扩展源文件(epel-release)即可:
[[email protected] yum.repos.d]# lsCentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo[[email protected] yum.repos.d]# yum install -y epel-release…… 已安装: epel-release.noarch 0:7-9 完毕![[email protected] yum.repos.d]# lsCentOS7-Base-163.repo CentOS-fasttrack.repo CentOS-Vault.repoCentOS-CR.repo CentOS-Media.repo epel.repoCentOS-Debuginfo.repo CentOS-Sources.repo epel-testing.repo
安装完成后,yum.repos.d/下增加“epel.repo”、“epel-testing.repo”两个文件:
[[email protected] yum.repos.d]# cat epel.repo[epel] name=Extra Packages for Enterprise Linux 7 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearchfailovermethod=priority enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7……
查看:
[[email protected] yum.repos.d]# yum list……zulucrypt-doc.noarch 5.0.1-1.el7 epel zulucrypt-libs.x86_64 5.0.1-1.el7 epel zvbi.x86_64 0.2.35-1.el7 epel ……
增加了很多来自epel库的rpm包。
下载rpm包
下载
命令:yum install -y [包名] --downloadonly
[[email protected] yum.repos.d]# yum install -y zsh --downloadonly已加载插件:fastestmirror Loading mirror speeds from cached hostfile …… zsh-5.0.2-25.el7_3.1.x86_64.rpm | 2.4 MB 00:00:02 exiting because "Download Only" specified [[email protected] yum.repos.d]# rpm -q zsh未安装软件包 zsh
即,该命令的含义就是只下载不安装。
下载的包默认保存位置为:
[[email protected] yum.repos.d]# ls /var/cache/yum/x86_64/7/updates/packageszsh-5.0.2-25.el7_3.1.x86_64.rpm
自定义下载目录
命令:yum install -y [包名] --downloadonly --downloaddir=/tmp/(自定义目录)
[[email protected] yum.repos.d]# yum install -y zsh --downloadonly --downloaddir=/tmp/[[email protected] yum.repos.d]# ls /tmp/zsh-5.0.2-25.el7_3.1.x86_64.rpm
下载一个已经安装过的包:
[[email protected] yum.repos.d]# yum install -y vim-enhanced --downloadonly --downloaddir=/tmp/已加载插件:fastestmirror Loading mirror speeds from cached hostfile * epel: mirror01.idc.hinet.net 软件包 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 已安装并且是最新版本 无须任何处理 [[email protected] yum.repos.d]# yum reinstall -y vim-enhanced --downloadonly --downloaddir=/tmp/已加载插件:fastestmirror …… [[email protected] yum.repos.d]# ls /tmp/vim-enhanced-7.4.160-1.el7_3.1.x86_64.rpm zsh-5.0.2-25.el7_3.1.x86_64.rpm
说明: 当下一个已经安装过的包时系统不会执行任何操作,此时可以使用“reinstall”来下该包。
7.8-7.9 源码包安装
先下载一个源码包!
注: 今后所有源码包放到目录“/usr/local/src/”!!!
[[email protected] src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz 下载Apache!该地址来自于“阿铭码市”。 下载完后解压该文件: [[email protected] src]# tar zxvf httpd-2.2.32.tar.gz[[email protected] src]# lshttpd-2.2.32 httpd-2.2.32.tar.gz 查看文件httpd-2.2.32的内容: [[email protected] src]# cd httpd-2.2.32[[email protected] httpd-2.2.32]# lsABOUT_APACHE CHANGES httpd.dsp libhttpd.dep NOTICE server acinclude.m4 config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclib Apache.dsw configure httpd.spec libhttpd.mak os support build configure.in include LICENSE README test BuildAll.dsp docs INSTALL Makefile.in README.platforms VERSIONING BuildBin.dsp emacs-style InstallBin.dsp Makefile.win README-win32.txt buildconf httpd.dep LAYOUT modules ROADMAP
安装Apache:
① [[email protected] httpd-2.2.32]# ./configure --prefix=/usr/local/apache2checking for chosen layout... Apache checking for working mkdir -p... yes …… checking for chosen layout... apr checking for gcc... nochecking for cc... no当某命令运行结束后,使用"echo $?"检验其是否正确: [[email protected] httpd-2.2.32]# echo $?1当该值为0时表示上一条命令正确,如果值为1则错误。 此处值为1,即上面命令错误,查看其安装过程发现“checking for gcc... no”——表示“gcc”编译器不存在,所以需要先安装gcc编译器: [[email protected] httpd-2.2.32]# yum install -y gcc………… 完毕! [[email protected] httpd-2.2.32]# ./configure --prefix=/usr/local/apache2再次安装。 [[email protected] httpd-2.2.32]# echo $?0检测,正确。 ② [[email protected] httpd-2.2.32]# make 编译!…… [[email protected] httpd-2.2.32]# echo $?0③ [[email protected] httpd-2.2.32]# make install…… [[email protected] httpd-2.2.32]# echo $?0每次命令执行完后用“echo $?”进行检测,确保其正确。 安装完成! 查看其安装目录的内容: [[email protected] httpd-2.2.32]# ls /usr/local/apache2/bin build cgi-bin conf error htdocs icons inc
本文出自 “芬野_de博客” 博客,请务必保留此出处http://yuanhaohao.blog.51cto.com/7714752/1981859
以上是关于yum下载rpm包及源码包安装的主要内容,如果未能解决你的问题,请参考以下文章
7.6 yum更换国内源 7.7 yum下载rpm包 7.8/7.9 源码包安装