7.6 yum更换国内源
恢复系统默认yum源配置:
[root@aminglinux-001 Packages]# cd /etc/yum.repos.d
[root@aminglinux-001 yum.repos.d]# ls
dvd.repo
[root@aminglinux-001 yum.repos.d]# rm -f dvd.repo
[root@aminglinux-001 yum.repos.d]# ls
[root@aminglinux-001 yum.repos.d]# cp ../yum.repos.d.bak/* .
[root@aminglinux-001 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
-
自定义yum源:
[root@aminglinux-001 yum.repos.d]# rm -f CentOS-Base.repo
先删除默认yum源,然后使用wget命令建立新yum源:
[root@aminglinux-001 yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
-bash: wget: 未找到命令
此时wget命令未安装,同时删除了yum源文件,无法安装wget包。
所以用下面的方法:“curl命令”
[root@aminglinux-001 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 8959 0 --:--:-- --:--:-- --:--:-- 8982
[root@aminglinux-001 yum.repos.d]# ls
CentOS7-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@aminglinux-001 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=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=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
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/? release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
"CentOS7-Base-163.repo" 41L, 1572C
7.7 yum下载rpm包
安装扩展源epel 安装一个扩展源文件(epel-release)即可:
[root@aminglinux-001 ~]# cd /etc/yum.repos.d
[root@aminglinux-001 yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
[root@aminglinux-001 ~]# yum install -y epel-release
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 6.1 kB 00:00:00
epel | 4.3 kB 00:00:00
https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/repodata/repomd.xml: [Errno -1] repomd.xml does not match metalink for epel
......
正在更新 : epel-release-7-10.noarch 1/2
清理 : epel-release-7-9.noarch 2/2
验证中 : epel-release-7-10.noarch 1/2
验证中 : epel-release-7-9.noarch 2/2
更新完毕:
epel-release.noarch 0:7-10
完毕!
[root@aminglinux-001 yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo epel.repo
CentOS-Debuginfo.repo CentOS-Sources.repo epel-testing.repo
安装完成后,yum.repos.d/下增加“epel.repo”、“epel-testing.repo”两个文件:
[root@aminglinux-001 yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
...... 查看
[root@aminglinux-001 yum.repos.d]# yum list |grep epel
* epel: mirrors.tuna.tsinghua.edu.cn
......
-
下载rpm包 命令:yum install -y [包名] --downloadonly
[root@aminglinux-001 yum.repos.d]# yum install -y zsh --doenloadonly 已加载插件:fastestmirror Usage: yum [options] COMMAND List of Commands: ...... zsh-5.0.2-25.el7_3.1.x86_64.rpm | 2.4 MB 00:00:00
exiting because "Download Only" specified 该命令的含义就是只下载不安装。 下载的包保存位置:
[root@aminglinux-001 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/(自定义目录)
[root@aminglinux-001 yum.repos.d]# yum install -y zsh --downloadonly --downloaddir=/tmp/
[root@aminglinux-001 yum.repos.d]# ls /tmp/
yum_save_tx.2017-08-30.11-53.0RN0tc.yumtx
zsh-5.0.2-25.el7_3.1.x86_64.rpm
下载一个已经安装过的包:
[root@aminglinux-001 yum.repos.d]# yum install -y vim-enhanced -- downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.tuna.tsinghua.edu.cn
软件包 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 已安装并且是最新版本
无须任何处理
[root@aminglinux-001 yum.repos.d]# yum reinstall -y vim-enhanced -- downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.tuna.tsinghua.edu.cn
......
[root@aminglinux-001 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@aminglinux-001 src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
[root@aminglinux-001 src]# ls
httpd-2.2.34.tar.gz
[root@aminglinux-001 src]#tar -zxvf httpd-2.2.34.tar.gz //解压该文件夹//
[root@aminglinux-001 src]# ls
httpd-2.2.34 httpd-2.2.34.tar.gz
[root@aminglinux-001 src]# cd httpd-2.2.34
[root@aminglinux-001 httpd-2.2.34]# ls
ABOUT_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@aminglinux-001 httpd-2.2.34]# ./configure -- prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
......
checking for gcc... no
checking for cc... no
checking for cl.exe... no
当某命令运行结束后,使用"echo $?"检验其是否正确:
[root@aminglinux-001 httpd-2.2.34]# echo $?
1
当该值为0时表示上一条命令正确,如果值为1则错误。
此处值为1,即上面命令错误,查看其安装过程发现“checking for gcc... no”——表示“gcc”编译器不存在,所以需要先安装gcc
[root@aminglinux-001 httpd-2.2.34]# yum install -y gcc
......
作为依赖被升级:
glibc.x86_64 0:2.17-157.el7_3.5 glibc-common.x86_64 0:2.17-157.el7_3.5
完毕!
[root@aminglinux-001 httpd-2.2.34]# ./configure-- prefix=/usr/local/apache2
再次安装
[root@aminglinux-001 httpd-2.2.34]# echo $?
0
[root@aminglinux-001 httpd-2.2.34]# make //编译//
[root@aminglinux-001 httpd-2.2.34]# echo $?
0
[root@aminglinux-001 httpd-2.2.34]# make install
[root@aminglinux-001 httpd-2.2.34]# echo $?
0
[root@aminglinux-001 httpd-2.2.34]# ls /usr/local/apache2/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
扩展
配置yum源优先级 http://ask.apelearn.com/question/7168 把源码包打包成rpm包 http://www.linuxidc.com/Linux/2012-09/70096.htm