码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-04-20 10:55:15      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:yum更换国内源yum下载rpm包源

yum更换国内源
  • 删除国外源CentOS-Base.repo

[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@localhost yum.repos.d]# rm -f CentOS-Base.repo 
[root@localhost yum.repos.d]# 
[root@localhost 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   7271      0 --:--:-- --:--:-- --:--:--  7311
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@localhost yum.repos.d]# 

之后可以安装一个rpm包试一下

[root@localhost yum.repos.d]# yum install -y wget
已加载插件:fastestmirror
base                                                                                                                         | 3.6 kB  00:00:00     
extras                                                                                                                       | 3.4 kB  00:00:00     
updates                                                                                                                      | 3.4 kB  00:00:00     
Determining fastest mirrors
正在解决依赖关系
--> 正在检查事务
---> 软件包 wget.x86_64.0.1.14-13.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

====================================================================================================================================================
 Package                          架构                               版本                                    源                                大小
====================================================================================================================================================
正在安装:
 wget                             x86_64                             1.14-13.el7                             base                             546 k

事务概要
====================================================================================================================================================
安装  1 软件包

总下载量:546 k
安装大小:2.0 M
Downloading packages:
wget-1.14-13.el7.x86_64.rpm                                                                                                  | 546 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : wget-1.14-13.el7.x86_64                                                                                                         1/1 
  验证中      : wget-1.14-13.el7.x86_64                                                                                                         1/1 

已安装:
  wget.x86_64 0:1.14-13.el7                                                                                                                         

完毕!
[root@localhost yum.repos.d]# 

安装扩展源epel

  • yum install -y epel-release

[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo

[root@localhost yum.repos.d]# yum install -y epel-release
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-9 将被 安装
--> 解决依赖关系完成
完毕!

[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo  epel-testing.repo
CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  epel.repo
[root@localhost yum.repos.d]# 

多了两个安装源

yum下载rpm包

  • 仅下载不安装:[root@localhost yum.repos.d]# yum install zsh --downloadonly

  • 下载位置在:/var/cache/yum/x86_64/7/仓库名/packages/

[root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/updates/packages/
zsh-5.0.2-25.el7_3.1.x86_64.rpm
  • 指定下载目录:-- downloadonly --downloaddir=/tmp/

[root@localhost yum.repos.d]# yum install zsh --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirrors.neusoft.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 zsh.x86_64.0.5.0.2-25.el7_3.1 将被 安装
--> 解决依赖关系完成

[root@localhost yum.repos.d]# ls /tmp/
1.txt                                                                     
1.txt.gz 
zsh-5.0.2-25.el7_3.1.x86_64.rpm
[root@localhost yum.repos.d]# 
  • 如果下载已经安装过的rpm包会提示已经安装,不会下载。除了卸载已经安装的包重新下载外还有一个方法:yum reinstall

[root@localhost yum.repos.d]# yum install vim-enhanced --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * epel: ftp.jaist.ac.jp
软件包 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 已安装并且是最新版本
无须任何处理

[root@localhost yum.repos.d]# yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 vim-enhanced.x86_64.2.7.4.160-1.el7_3.1 将被 已重新安装
--> 解决依赖关系完成

源码包安装

  • 首先需要根据自己需求下载一个源码包

    约定:以后源码包下载好后放到cd /usr/local/src/下

  • 可以下载一个apache进行安装实验

[root@localhost yum.repos.d]# cd /usr/local/src/
[root@localhost src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
--2017-08-29 22:37:00--  http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
正在解析主机 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.178, 2402:f000:1:416:101:6:6:177
正在连接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.178|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:http://219.239.26.14/files/5162000009CC51A1/mirror.bit.edu.cn/apache//httpd/httpd-2.2.32.tar.gz [跟随至新的 URL]
--2017-08-29 22:37:00--  http://219.239.26.14/files/5162000009CC51A1/mirror.bit.edu.cn/apache//httpd/httpd-2.2.32.tar.gz
正在连接 219.239.26.14:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:7684420 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.32.tar.gz”

100%[==========================================================================================================>] 7,684,420   1.43MB/s 用时 5.1s   

2017-08-29 22:37:06 (1.43 MB/s) - 已保存 “httpd-2.2.32.tar.gz” [7684420/7684420])

[root@localhost src]# ls
httpd-2.2.32.tar.gz
  • 解压包 :tar zxvf -zxvf httpd-2.2.32.tar.gz

  • 查看源码包

[root@localhost src]# ls
httpd-2.2.32  httpd-2.2.32.tar.gz
[root@localhost src]# cd httpd-2.2.32
[root@localhost httpd-2.2.32]# ls
ABOUT_APACHE  BuildAll.dsp  config.layout  emacs-style  httpd.spec      LAYOUT        LICENSE       NOTICE         README.platforms  srclib
acinclude.m4  BuildBin.dsp  configure      httpd.dep    include         libhttpd.dep  Makefile.in   NWGNUmakefile  README-win32.txt  support
Apache.dsw    buildconf     configure.in   httpd.dsp    INSTALL         libhttpd.dsp  Makefile.win  os             ROADMAP           test
build         CHANGES       docs           httpd.mak    InstallBin.dsp  libhttpd.mak  modules       README         server            VERSIONING
[root@localhost httpd-2.2.32]# 
  • 查看源码包INSTALL文件里面有提示安装方法

    For complete installation documentation, see [ht]docs/manual/install.html or
    http://httpd.apache.org/docs/2.2/install.html
    
     $ ./configure --prefix=PREFIX
     $ make
     $ make install
     $ PREFIX/bin/apachectl start
  • 安装源码包

[root@localhost httpd-2.2.32]# ./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
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.32/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.32]# 

这条命令执行是有报错的。查看上一条命令执行的有没有报错输入“echo $?”。输出结果不是0说明有报错

报错说明gcc不存在,这样的话yum安装一下,yum install gcc

  • 之后再进行安装,看看还有没有错,如果还有错就会停下来告诉哪里有问题。

[root@localhost httpd-2.2.32]# echo $?
0

安装完之后检测echo $? 是0 ,说明没有问题

  • 之后该make了

大概等两分钟的样子之后完成,然后查看有没有错误

[root@localhost httpd-2.2.32]# echo $?
0
  • 之后该make install

这条命令是安装编译好的文件

查看目录下都安装了什么


[root@localhost httpd-2.2.32]# ls /usr/local/apache2/
bin  build  cgi-bin  conf  error  htdocs  icons  include  lib  logs  man  manual  modules
[root@localhost httpd-2.2.32]# 

- ### 卸载就是删除安装的文件

- ### 下载源码包一定要注意安全,去官方或者可信任站点下载

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

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

标签:yum更换国内源yum下载rpm包源

原文地址:http://blog.51cto.com/11751505/2105637

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!