系统内置的源很多时候都是官方的,大部分在国外,使用起来不是很快,也很难下载,这时候最好使用国内的源,如163
mv CentOS-Base.repo CentOS-Base.repo.bak
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
或者curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum install wget
经常很多软件在某些源中没有,这时候就需要扩展多个源来满足需求,比如安装扩展epel源就非常有用。
a.yum install -y epel-release
##安装epel
b.yum list |grep epel
##验证是否生效
yum install -y 包名 --downloadonly
##默认存放位置yum install -y 包名 --downloadonly --downloaddir=路径
##指定存放位置
[root@centos701 ~]# yum install zsh --downloadonly [root@centos701 ~]# yum install zsh --downloadonly 已加载插件:fastestmirror........... ================================================================================================ Package 架构 版本 源 大小 ================================================================================================正在安装: zsh x86_64 5.0.2-28.el7 base 2.4 M事务概要 ================================================================================================安装 1 软件包 总下载量:2.4 M 安装大小:5.6 M Background downloading packages, then exiting: zsh-5.0.2-28.el7.x86_64.rpm | 2.4 MB 00:00:00 exiting because "Download Only" specified [root@centos701 ~]# ls /var/cache/yum/x86_64/7/ base/ epel/ .gpgkeyschecked.yum timedhosts.txt dvd/ extras/ timedhosts updates/ [root@centos701 ~]# ls /var/cache/yum/x86_64/7/base/packages/ zsh-5.0.2-28.el7.x86_64.rpm 下载完成后去/var/cache/yum/x86_64/7/目录下的 base 目录中就可以找到刚刚下载的文件
yum reinstall -y 包名 --downloadonly
##默认目录yum reinstall -y 包名 --downloadonly --downloaddir=路径
##指定目录
由于常见源码包都是由 C语言开发的,所以操作前请安装好 gcc 编辑器
yum install -y gcc
尽量去官方或者可靠的站点下载源码包
将源码包统一放在:/usr/local/src目录
http://r.aminglinux.com 下载相应版本的源码包
**源码安装关键三步 **
1 ./configure
2 make
3 make install
详细操作 以 Apache 为例
[root@centos701 src]#wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
[root@centos701 src]#tar -zxvf httpd-2.2.34.tar.gz
在软件目录下查找安装说明,一般是README与INSTALL
[root@centos701 httpd-2.2.34]#./configure --prefix=/usr/local/apache2creating srclib/pcre/Makefile creating test/Makefile config.status: creating docs/conf/httpd.conf config.status: creating docs/conf/extra/httpd-autoindex.conf config.status: creating docs/conf/extra/httpd-dav.conf config.status: creating docs/conf/extra/httpd-default.conf config.status: creating docs/conf/extra/httpd-info.conf ............ [root@centos701 httpd-2.2.34]# echo $? ##检测上一条命令执行是否有错,非0为有错,反之则表示配置成功0[root@centos701 httpd-2.2.34]# ls -l Makefile ##确认配置好的Makefile-rw-r--r--. 1 root root 8954 11月 14 23:14 Makefile
[root@centos701 httpd-2.2.34]# make ##此过程耗时取决于机器性能............. Making all in pcre make[2]: 进入目录“/usr/local/src/httpd-2.2.34/srclib/pcre” make[3]: 进入目录“/usr/local/src/httpd-2.2.34/srclib/pcre” ............... [root@centos701 httpd-2.2.34]# echo $? ##养成习惯,完成一步立即检测0[root@centos701 httpd-2.2.34]#
由于在配置时候只自定义了安装路径,故其他参数设置等一律软件默认
[root@centos701 httpd-2.2.34]# make installMaking install in srclib make[1]: 进入目录“/usr/local/src/httpd-2.2.34/srclib” Making install in apr make[2]: 进入目录“/usr/local/src/httpd-2.2.34/srclib/apr” make[3]: 进入目录“/usr/local/src/httpd-2.2.34/srclib/apr” make[3]: 对“local-all”无需做任何事。 ........ mkdir /usr/local/apache2/man/man8 mkdir /usr/local/apache2/manual make[1]: 离开目录“/usr/local/src/httpd-2.2.34” [root@centos701 httpd-2.2.34]# echo $?0[root@centos701 httpd-2.2.34]#
到这里,基于源码包的 Apache 就安装好了
5周第2次课 yum更换国内源 yum下载rpm包 源码包安装
原文地址:http://badswolf.blog.51cto.com/6725328/1981857