7.6 yum更换国内源
-
恢复系统默认yum源配置:
[root@adai002 Packages]# cd /etc/yum.repos.d[root@adai002 yum.repos.d]# lsdvd.repo [root@adai002 yum.repos.d]# rm -f dvd.repo[root@adai002 yum.repos.d]# ls[root@adai002 yum.repos.d]# cp ../yum.repos.d.bak/* .[root@adai002 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源:
[root@adai002 yum.repos.d]# rm -f CentOS-Base.repo先删除默认yum源,然后使用wget命令建立新yum源: [root@adai002 yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo-bash: wget: 未找到命令 此时wget命令未安装,同时删除了yum源文件,无法安装wget包。 所以用下面的方法:“curl命令” [root@adai002 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[root@adai002 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源文件:
[root@adai002 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)即可:
[root@adai002 yum.repos.d]# lsCentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo[root@adai002 yum.repos.d]# yum install -y epel-release…… 已安装: epel-release.noarch 0:7-9 完毕![root@adai002 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”两个文件:
[root@adai002 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……
查看:
[root@adai002 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
[root@adai002 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 [root@adai002 yum.repos.d]# rpm -q zsh未安装软件包 zsh
即,该命令的含义就是只下载不安装。
下载的包默认保存位置为:
[root@adai002 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/(自定义目录)
[root@adai002 yum.repos.d]# yum install -y zsh --downloadonly --downloaddir=/tmp/[root@adai002 yum.repos.d]# ls /tmp/zsh-5.0.2-25.el7_3.1.x86_64.rpm
下载一个已经安装过的包:
[root@adai002 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 已安装并且是最新版本 无须任何处理 [root@adai002 yum.repos.d]# yum reinstall -y vim-enhanced --downloadonly --downloaddir=/tmp/已加载插件:fastestmirror …… [root@adai002 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/”!!!
[root@adai002 src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz 下载Apache!该地址来自于“阿铭码市”。 下载完后解压该文件: [root@adai002 src]# tar zxvf httpd-2.2.32.tar.gz[root@adai002 src]# lshttpd-2.2.32 httpd-2.2.32.tar.gz 查看文件httpd-2.2.32的内容: [root@adai002 src]# cd httpd-2.2.32[root@adai002 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:
① [root@adai002 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 $?"检验其是否正确: [root@adai002 httpd-2.2.32]# echo $?1当该值为0时表示上一条命令正确,如果值为1则错误。 此处值为1,即上面命令错误,查看其安装过程发现“checking for gcc... no”——表示“gcc”编译器不存在,所以需要先安装gcc编译器: [root@adai002 httpd-2.2.32]# yum install -y gcc………… 完毕! [root@adai002 httpd-2.2.32]# ./configure --prefix=/usr/local/apache2再次安装。 [root@adai002 httpd-2.2.32]# echo $?0检测,正确。 ② [root@adai002 httpd-2.2.32]# make 编译!…… [root@adai002 httpd-2.2.32]# echo $?0③ [root@adai002 httpd-2.2.32]# make install…… [root@adai002 httpd-2.2.32]# echo $?0每次命令执行完后用“echo $?”进行检测,确保其正确。 安装完成! 查看其安装目录的内容: [root@adai002 httpd-2.2.32]# ls /usr/local/apache2/bin build cgi-bin conf error htdocs icons inc
本文转自 芬野 51CTO博客,原文链接:http://blog.51cto.com/yuanhaohao/1981859,如需转载请自行联系原作者