yum更换国内源、yum下载rpm包、源码包安装

2018-01-22  本文已影响0人  强出头

76 yum更换国内源

更换基础仓库源
[root@localhost yum.repos.d]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls
dvd.repo
[root@localhost yum.repos.d]# rm -f dvd.repo 
[root@localhost yum.repos.d]# cp ../yum.repos.d.bak/* .(删除之前的本地仓库后恢复之前的文件)
[root@localhost 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
[root@localhost yum.repos.d]# rm -f CentOS-Base.repo (删除核心文件)
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo(下载替换文件)
--2018-01-18 11:12:58--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1572 (1.5K) [application/octet-stream]
正在保存至: “CentOS7-Base-163.repo”

100%[======================================>] 1,572       --.-K/s 用时 0.006s  

2018-01-18 11:12:58 (254 KB/s) - 已保存 “CentOS7-Base-163.repo” [1572/1572])

[root@localhost 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@localhost yum.repos.d]# yum list

77 yum下载rpm包

更换yum仓库源

[root@localhost yum.repos.d]# yum install -y apel-release(安装或更新release)
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
没有可用软件包 apel-release。
错误:无须任何处理
[root@localhost yum.repos.d]# yum list(会发现更多的包)
yum下载rpm包
[root@localhost yum.repos.d]# yum install zsh --downloadonly(仅下载rpm包)
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 zsh.x86_64.0.5.0.2-28.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 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:14     
exiting because "Download Only" specified
[root@localhost yum.repos.d]# yum install zsh --downloadonly /tmp/(指定路径)
yum下载rpm包

78 源码包安装(上)

源码包安装

约定源码包下载放入路径
/usr/local/src/

[root@localhost yum.repos.d]# cd /usr/local/src/
[root@localhost src]# wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.2.34.tar.gz(下载源码包)
--2018-01-18 15:04:59--  http://mirror.bit.edu.cn/apache//httpd/httpd-2.2.34.tar.gz
正在解析主机 mirror.bit.edu.cn (mirror.bit.edu.cn)... 202.204.80.77, 2001:da8:204:2001:250:56ff:fea1:22
正在连接 mirror.bit.edu.cn (mirror.bit.edu.cn)|202.204.80.77|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:7684419 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.34.tar.gz”

100%[======================================>] 7,684,419    116KB/s 用时 2m 7s  

2018-01-18 15:07:06 (59.2 KB/s) - 已保存 “httpd-2.2.34.tar.gz” [7684419/7684419])
[root@localhost src]# tar -zxvf httpd-2.2.34.tar.gz (解压)
[root@localhost httpd-2.2.34]# more INSTALL (安装帮助文档)
     $ ./configure --prefix=PREFIX
     $ make
     $ make install
     $ PREFIX/bin/apachectl start
(官方建议安装步骤和方法,大多都是这样安装得)
[root@localhost httpd-2.2.34]# ./configure --prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu

Configuring Apache Portable Runtime library ...

checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.2
checking for chosen layout... apr
checking for gcc... no(gcc不存在)
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.34/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
configure failed for srclib/apr
[root@localhost httpd-2.2.34]# echo $?(上一条命令是否正常,0为正常,1为与错误)
1
(gcc不存在,安装gcc)
[root@localhost ~]# yum install -y gcc(安装gcc)
[root@localhost httpd-2.2.34]# ./configure --prefix=/usr/local/apache2(指定目录编译)
[root@localhost httpd-2.2.34]# echo $? (查看命令是否执行正确,0表示正确)
0
[root@localhost httpd-2.2.34]# make
[root@localhost httpd-2.2.34]# echo $?
0
[root@localhost httpd-2.2.34]# make install(生成目录并分布进去)
[root@localhost httpd-2.2.34]# echo $?
0

卸载就是删除指定目录就可以了
一定去官方下载源码包
扩展

  1. 配置yum源优先级 http://ask.apelearn.com/question/7168
  2. 把源码包打包成rpm包 http://www.linuxidc.com/Linux/2012-09/70096.htm
上一篇下一篇

猜你喜欢

热点阅读