## 7.6 yum更换国内源
**恢复备份:**
```
[root@localhost yum.repos.d]# cp ../yum.repos.d.bak/* .
```
**下载yum源:**
```
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
```
**改名:**
```
[root@localhost yum.repos.d]# mv CentOS7-Base-163.repo ./CentOS-Base.repo
```
**清除缓存:**
```
[root@localhost yum.repos.d]# yum clean all
```
**重新生成缓存:**
```
[root@localhost yum.repos.d]# yum install zsh
```
***
## 7.7 yum下载rpm包
**安装扩展源:**
```
[root@localhost ~]# yum install -y epel-release
```
**使用yum下载rpm包:**
**仅下载不安装:**
```
[root@localhost yum.repos.d]# yum install zsh --downloadonly
```
**查询rpm包是否安装:**
```
[root@localhost yum.repos.d]# rpm -q zsh
```
**指定下载路径:**
```
[root@localhost yum.repos.d]# yum install zsh --downloadonly --downloaddir=/tmp/
```
**将已安装的软件下载到指定目录:**
```
[root@localhost yum.repos.d]# yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
```
***
## 7.8 源码包安装(上)
> 将源码包放在 /usr/local/src目录中
**下载apache:**
```
[root@localhost src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
```
**解压:**
```
[root@localhost src]# tar -zxvf httpd-2.2.32.tar.gz
```
**安装apache:**
```
[root@localhost httpd-2.2.32]# ./configure --prefix=/usr/local/apache2
```
**查看上一条命令运行是否正确:**
```
[root@localhost httpd-2.2.32]# echo $?
1
```
* 非0表示上一条命令运行错误
> checking for gcc... no表示gcc编译器不存在
```
[root@localhost httpd-2.2.32]# make
```
**扩展:**
> 1. 配置yum源优先级 http://www.aminglinux.com/bbs/thread-7168-1-1.html
> 2. 把源码包打包成rpm包 http://www.linuxidc.com/Linux/2012-09/70096.htm
## 7.9 源码包安装(下)
```
[root@localhost httpd-2.2.32]# make install
```
转载于:https://blog.51cto.com/13017724/1942881