2019独角兽企业重金招聘Python工程师标准>>>

更换国内yum源

我们的Linux中默认的yum源是国外的,有的时候网络不好,而我么需要下载的包过大的时候更换成国内的yum源,安装的效率就会提升很多,接下来就讲一下怎么更换yum源。

  1. 前一天做过了本地yum源,光盘中的包并不是那么全,也不一定是最新的版本,所以今天就把本地yum源给删掉,并把之前备份的yum源还原
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls
dvd.repo
[root@localhost yum.repos.d]# rm -f dvd.repo
[root@localhost etc]# mv /tmp/yum.repos.d.bak/ /etc/yum.repos.d
[root@localhost etc]# cd yum.repos.d
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo

如果没做过本地yum源可以忽略这一步。

  1. 删除掉yum源的核心文件 CentOS-Base.repo
[root@localhost yum.repos.d]# rm CentOS-Base.repo
rm:是否删除普通文件 "CentOS-Base.repo"?y
  1. 获取yum源(yum源地址是已知的)wget http://mirrors.163.com/.help/CentOS7-Base-163.repo (如果系统没有wget,而且这个时候删除了yum源的核心文件了,是安装不了的,可以使用curl-O(这是个大写的O) http://mirrors.163.com/.help/CentOS7-Base-163.repo 代替)
[root@localhost yum.repos.d]# curl -O  http://mirrors.163.com/.help/CentOS7-Base-163.repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100  1572  100  1572    0     0   6437      0 --:--:-- --:--:-- --:--:--  6469
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo
  1. 可以使用vim /etc/yum.repos.d/CentOS7-Base-163.repo 看一下它的镜像地址
  2. yum clean all 生成新的缓存,使用yum list 验证是否生效,可以安装一下wget
[root@localhost yum.repos.d]# yum list | more
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
已安装的软件包
ModemManager-glib.x86_64                   1.1.0-6.git20130913.el7     @anaconda
NetworkManager.x86_64                      1:0.9.9.1-13.git20140326.4dba720.el7@anaconda
NetworkManager-glib.x86_64                 1:0.9.9.1-13.git20140326.4dba720.el7@anaconda
NetworkManager-tui.x86_64                  1:0.9.9.1-13.git20140326.4dba720.el7@anaconda
acl.x86_64                                 2.2.51-12.el7               @anaconda
aic94xx-firmware.noarch                    30-6.el7                    @anaconda
alsa-firmware.noarch                       1.0.27-2.el7                @anaconda
[root@localhost yum.repos.d]# yum install -y wget

更换yum源已经生效了。

安装扩展源

有些时候有些包国内的源站不具备,这个时候可以安装一个扩展yum源,扩展源中的包比较全面。yum install -y epel-release 安装完之后可以使用yum list | grep epel | more 分屏查看扩展源提供了哪些包

[root@localhost yum.repos.d]# yum install -y epel-release
[root@localhost yum.repos.d]# yum list | grep epel | more* epel: mirrors.tuna.tsinghua.edu.cn
epel-release.noarch                      7-11                          @extras
0ad.x86_64                               0.0.22-1.el7                  epel
0ad-data.noarch                          0.0.22-1.el7                  epel
0install.x86_64                          2.11-1.el7                    epel
2048-cli.x86_64                          0.9.1-1.el7                   epel
2048-cli-nocurses.x86_64                 0.9.1-1.el7                   epel
2ping.noarch                             3.2.1-2.el7                   epel
389-admin.x86_64                         1.1.46-1.el7                  epel
389-admin-console.noarch                 1.1.12-1.el7                  epel
389-admin-console-doc.noarch             1.1.12-1.el7                  epel
389-adminutil.x86_64                     1.1.21-2.el7                  epel
389-adminutil-devel.x86_64               1.1.21-2.el7                  epel
389-console.noarch                       1.1.18-1.el7                  epel
389-ds.noarch                            1.2.2-6.el7                   epel
389-ds-console.noarch                    1.2.16-1.el7                  epel
389-ds-console-doc.noarch                1.2.16-1.el7                  epel
389-dsgw.x86_64                          1.1.11-5.el7                  epel
3proxy.x86_64                            0.7-1.el7                     epel
3proxy-sysvinit.x86_64                   0.7-1.el7                     epel
4diac-forte.x86_64                       1.9.0-0.1.M3.el7              epel
90-Second-Portraits.noarch               1.01b-3.el7                   epel
Agda.x86_64                              2.3.2.2-5.el7                 epel
AntTweakBar.x86_64                       1.16-2.el7                    epel
AntTweakBar-devel.x86_64                 1.16-2.el7                    epel
BEDTools.x86_64                          2.26.0-1.el7                  epel
BackupPC.x86_64                          3.3.1-5.el7                   epel

yum 下载rpm包

当我们需要一个rpm包,但是不安装在当前机器上时可以使用yum install 包名 --downloadonly命令。 默认下载的rpm包放在/var/cache/yum/x86_64/7/Base/packges下,不一定是Base/packages ,得看包是来源哪个yum源,也就是下面代码中的源

[root@localhost ~]# yum install CBFlib --downloadonly
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile* epel: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 CBFlib.x86_64.0.0.9.5.1-1.el7 将被 安装
--> 正在处理依赖关系 libgfortran.so.3(GFORTRAN_1.0)(64bit),它被软件包 CBFlib-0.9.5.1-1.el7.x86_64 需要
--> 正在处理依赖关系 libquadmath.so.0()(64bit),它被软件包 CBFlib-0.9.5.1-1.el7.x86_64 需要
--> 正在处理依赖关系 libhdf5.so.8()(64bit),它被软件包 CBFlib-0.9.5.1-1.el7.x86_64 需要
--> 正在处理依赖关系 libgfortran.so.3()(64bit),它被软件包 CBFlib-0.9.5.1-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 hdf5.x86_64.0.1.8.12-10.el7 将被 安装
--> 正在处理依赖关系 libsz.so.2()(64bit),它被软件包 hdf5-1.8.12-10.el7.x86_64 需要
---> 软件包 libgfortran.x86_64.0.4.8.5-28.el7_5.1 将被 安装
---> 软件包 libquadmath.x86_64.0.4.8.5-28.el7_5.1 将被 安装
--> 正在检查事务
---> 软件包 libaec.x86_64.0.1.0.2-1.el7 将被 安装
--> 解决依赖关系完成依赖关系解决===============================================================================================================================================================================================Package                                        架构                                      版本                                                源                                          大小
===============================================================================================================================================================================================
正在安装:CBFlib                                         x86_64                                    0.9.5.1-1.el7                                       epel                                       349 k
为依赖而安装:hdf5                                           x86_64                                    1.8.12-10.el7                                       epel                                       1.6 Mlibaec                                         x86_64                                    1.0.2-1.el7                                         epel                                        33 klibgfortran                                    x86_64                                    4.8.5-28.el7_5.1                                    updates                                    299 klibquadmath                                    x86_64                                    4.8.5-28.el7_5.1                                    updates                                    188 k事务概要
===============================================================================================================================================================================================
安装  1 软件包 (+4 依赖软件包)总下载量:2.4 M
安装大小:11 M
Background downloading packages, then exiting:
警告:/var/cache/yum/x86_64/7/epel/packages/CBFlib-0.9.5.1-1.el7.x86_64.rpm.2480.tmp: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY                     ]  0.0 B/s |    0 B  --:--:-- ETA
CBFlib-0.9.5.1-1.el7.x86_64.rpm.2480.tmp 的公钥尚未安装
(1/5): CBFlib-0.9.5.1-1.el7.x86_64.rpm                                                                                                                                  | 349 kB  00:00:00
(2/5): hdf5-1.8.12-10.el7.x86_64.rpm                                                                                                                                    | 1.6 MB  00:00:00
(3/5): libaec-1.0.2-1.el7.x86_64.rpm                                                                                                                                    |  33 kB  00:00:00
(4/5): libquadmath-4.8.5-28.el7_5.1.x86_64.rpm                                                                                                                          | 188 kB  00:00:00
(5/5): libgfortran-4.8.5-28.el7_5.1.x86_64.rpm                                                                                                                          | 299 kB  00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                           1.3 MB/s | 2.4 MB  00:00:01
exiting because "Download Only" specified
[root@localhost ~]# cd /var/cache/yum/x86_64/7/epel/
[root@localhost epel]# ls
15dc600c8998af6bdd140f116f907c7ba300b57a0f9e694478b8e614da1e568c-primary.xml.gz                  gen
197befceaa417137427a2acb762989b9678018468f8ed87cd09c15ccf26aa416-updateinfo.xml.bz2              metalink.xml
cachecookie                                                                                      packages
e3bc6715aed495af6183f53de6a1559908aa315c8fdad84cb8b4281f559e0d71-comps-Everything.x86_64.xml.gz  repomd.xml
[root@localhost epel]# cd packages/
[root@localhost packages]# ls      可以看到我们下载的rpm包在这里(它会下载很多有依赖关系的包,不一定只在一个目录下)
CBFlib-0.9.5.1-1.el7.x86_64.rpm  hdf5-1.8.12-10.el7.x86_64.rpm  libaec-1.0.2-1.el7.x86_64.rpm

还可以指定路径yum install 包名 --downloadonly --downloaddir=/tmp/ 如果要下载的包已经安装过了会提示nothing to do ,可以将命令中的install改成reinstall,并且可以在命令后面加--downloaddir来指定下载的目录

[root@localhost packages]# yum install vim-enhanced --downloadonly
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile* epel: mirrors.tuna.tsinghua.edu.cn
软件包 2:vim-enhanced-7.4.160-4.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost packages]# yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
[root@localhost packages]# cd /tmp
[root@localhost tmp]# ls
1.txt      222    3.txt   dabao.tar       test       test3.zip  vim-enhanced-7.4.160-4.el7.x86_64.rpm      yum_save_tx.2018-06-28.08-05.BUHLOs.yumtx
1.txt.bz2  2.txt  44.txt  form154853.pdf  test1.zip  test.zip   yum_save_tx.2018-06-28.07-48.9Lb2Kb.yumtx

可以看到虽然vim-enhanced这个包我们安装过了,但是使用reinstall还是可以成功的把它下载到指定目录的。

源码包安装

首先要根据自己的实际需求下载源码包 约定:源码包下载到/usr/local/src下 例子:安装Apache

  1. 下载源码包,wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz 如果该链接不能用了可以在浏览器输入r.aminglinux.com进入阿铭的码市选取自己需要的源码包链接
[root@localhost ~]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
--2018-06-28 08:21:41--  http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
正在解析主机 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.8.193|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9076901 (8.7M) [application/octet-stream]
正在保存至: “httpd-2.4.33.tar.gz”100%[=====================================================================================================================================================>] 9,076,901   5.58MB/s 用时 1.6s   2018-06-28 08:21:43 (5.58 MB/s) - 已保存 “httpd-2.4.33.tar.gz” [9076901/9076901])

2 . 安装完之后需要解压,tar -zxvf apache-2.4.33.tar.gz,解压完了之后可以进入apache-2.4.33目录下看一下说明README 和安装手册INSTALL

[root@localhost src]# ls
httpd-2.4.33  httpd-2.4.33.tar.gz
[root@localhost src]# cd httpd-2.4.33
[root@localhost httpd-2.4.33]# ls
ABOUT_APACHE     apache_probes.d  BuildBin.dsp    config.layout  emacs-style  httpd.spec      LAYOUT        LICENSE       NOTICE         README.cmake      srclib
acinclude.m4     ap.d             buildconf       configure      httpd.dep    include         libhttpd.dep  Makefile.in   NWGNUmakefile  README.platforms  support
Apache-apr2.dsw  build            CHANGES         configure.in   httpd.dsp    INSTALL         libhttpd.dsp  Makefile.win  os             ROADMAP           test
Apache.dsw       BuildAll.dsp     CMakeLists.txt  docs           httpd.mak    InstallBin.dsp  libhttpd.mak  modules       README         server            VERSIONING

3 . 运行./configure --prefix=/usr/lacal/pache2来指定安装目录 在安装的时候可能会遇到很多种报错

configure: error: APR not found.  Please read the documentation.

提示这个报错是因为没有安装apr包,需要下载并安装apr wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz

[root@localhost src]# ls
apr-1.6.3.tar.gz  httpd-2.4.33  httpd-2.4.33.tar.gz
[root@localhost src]# tar -zxf apr-1.6.3.tar.gz
[root@localhost src]# ls
apr-1.6.3  apr-1.6.3.tar.gz  httpd-2.4.33  httpd-2.4.33.tar.gz
[root@localhost src]# cd apr-1.6.3
[root@localhost apr-1.6.3]# ./configure --prefix=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.6.3
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/apr-1.6.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
  • 发现在装这个apr的时候出现了一个错误checking gcc....0 ,这里就需要yum install -y gcc 安装一下gcc

  • 当执行完一个指令后,我们不知道是不是执行成功了,可以使用echo $?来查看,当输出的是非0的数值时说明我们的上一条指令是有问题的。

  • 再使用./configure命令检查,没问题之后运行make命令编译,编译完之后运行echo $?查看编译有没有问题

  • 编译完之后就使用make install安装到之前指定的路径prefix=/usr/local/apr

  • 安装完之后发现还是不能安装Apache,这是因为还需要安装一个apr-util包 wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2 下载解压并安装

[root@localhost src]# tar -jxf apr-util-1.6.1.tar.bz2
[root@localhost src]# ls
apr-1.6.3  apr-1.6.3.tar.gz  apr-util-1.6.1  apr-util-1.6.1.tar.bz2  httpd-2.4.33  httpd-2.4.33.tar.gz
[root@localhost src]# cd apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/src/apr-1.6.3

同样的步骤,检查,编译,安装

  • 在编译的过程中会出现这样一个错误xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 这是因为没有expat,运行yum install expat-devel命令来安装,之后再编译就没有问题了。然后make install 安装。

4 。 安装完之后就该安装Apache了,在安装的时候时需要指定apr和apr-util的安装目录的路径的。

[root@localhost httpd-2.4.33]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr-1.6.3 --with-apr-util=/usr/local/apr-util-1.6.1
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yessetting CC to "gcc"setting CPP to "gcc -E"setting CFLAGS to " -g -O2 -pthread"setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@localhost httpd-2.4.33]# echo $?
1
  • 发现还是报错configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ 这是因为还需要安装一个pcre的包,这个包可以使用yum安装 yum install pcre-devel 这个包安装完之后再执行./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/src/apr-1.6.3 --with-apr-util=/usr/local/src/apr-util-1.6.1就可以看到Apache的检查过程了

4 . 使用make命令来编译,在编译的过程中又发生报错了

make[2]: *** [exports.lo] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.7/server'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.7/server'
make: *** [all-recursive] Error 1

要解决这个故障需要返回头去

# cd /usr/local/src/
# cp -r apr-1.6.3 /usr/local/src/httpd-2.4.33/srclib/apr
# cp -r apr-util-1.6.1 /usr/local/src/httpd-2.4.33/srclib/apr-util

然后再重新configure,使用./configure --with-included-apr命令就不会报错了 ,然后再make编译,make install安装就OK了。 目前在安装过程中遇到并解决掉的问题就这些。

转载于:https://my.oschina.net/u/3731306/blog/1836728

更换yum源,安装扩展源,yum下载rpm包,源码包安装软件相关推荐

  1. Centos7 安装mysql 需要自己下载 rpm

    一开始使用安装命令 :yum -y install mysql mysql-server mysql-devel 安装完成却发现Myserver安装缺失,在网上找原因,原来是因为CentOS 7上把M ...

  2. 安装keepalived所需rpm包安装顺序以及离线下载rpm包方式

    安装keepalived 1.3.5 所需rpm包以及安装顺序如下 1. rpm -ivh net-snmp-libs-5.7.2-38.el7_6.2.x86_64.rpm2. rpm -ivh p ...

  3. linux平台下rpm方式和源码包方式安装mysql5.7

    博主QQ:819594300 博客地址:http://zpf666.blog.51cto.com/ 有什么疑问的朋友可以联系博主,博主会帮你们解答,谢谢支持! 一.下载mysql的rpm包 Mysql ...

  4. 【Linux/内核】Linux内核rpm包和源码包下载地址-20210107

    1.有个需求:如何下载老版本内核rpm包? 因自己在按文档做实验时,为了实验期间涉及软件包版本保持一致,需要用到旧版本的内核rpm包,但是自己在内核下载页面并没找到相关的旧版本软件包,只有最近新版本的 ...

  5. 华硕固件安装扩展插件_华硕RT-AC86U官改固件-支持AiMesh+软件中心+ROG 3.0.0.4.384.20648...

    华硕RT-AC86U官方改版固件,支持更多功能AiMesh+软件中心+ROG,如果不满足官方自己的固件,可刷入此固件. 固件主要特色: 1. 同步华硕官方代码 2. koolshare软件中心支持 3 ...

  6. android apk安装工具,APK安装器下载-APK安装器手机版下载v2.9-1 安卓版-西西软件下载...

    APK安装器取代手机当中自带的APK安装器,让安装的界面在整体上面变得更加的好看,对于颜值有着极高要求的用户而言,虽然安装界面我们不一定能够经常的进行看到,但是界面的丑美也非常影响感官体验,感兴趣的话 ...

  7. 解决chrome安装扩展插件导入.crx文件提示:程序包无效的错误

    将.crx后缀改成.zip 然后解压 从应用商店中导入文件夹即可.

  8. linux软件安装——rpm、yum、源码包安装

    一.软件包分类 源码包(原始的c语言文件,开源) 二进制包(系统默认包,将源码编译为机器语言,省略了编译过程,安装较快,但是用户看不到源码,安装有依赖性,centos中都是rpm包) 二.rpm命令管 ...

  9. PHP 的源码编译安装

    PHP 架构和安装扩展的几种方式 PHP 三大模块: SAPI:接受并处理请求. Zend Engine:PHP 的核心,负责分析 PHP 代码并转为 opcode,然后在 Zend VM 虚拟机上执 ...

  10. Linux软件包管理之源码包、脚本安装包

    目录 1.源码包和RPM包的区别 RPM包和源码包默认安装位置: 由于安装位置不同带来的影响 2.源码包安装 ①.安装准备 ②.安装注意事项 ③.安装源码包 3.源码包卸载 4.脚本安装包 5.总结 ...

最新文章

  1. uva live 4394 String painter 间隔dp
  2. 【重构】微信小程序倒计时组件
  3. 如何让你的 JS 写得更漂亮,看这篇就对了!
  4. 征集.NET中国峰会议题
  5. Visual studio代码行数统计
  6. 2015 总结 2016 展望
  7. 所有C#程序员必须知道的13件事
  8. 将byte[]转为各种进制的字符串
  9. 项目管理软件 OpenProj
  10. java获取法定节假日
  11. LVM实现将2块磁盘总空间“合二为一”并挂载到同一目录/移除磁盘
  12. ROS项目开发实战(三)——使用QT进行ROS的GUI界面设计(详细教程附代码!!!)
  13. 注册最便宜的xyz域名,低成本搭建一个博客
  14. 解决error while loading shared libraries: xxx.so.x类似问题办法和错误原因
  15. Parker机电产品(运动控制/伺服电机/直线电机)在FPD行业应用
  16. 用PDFPrint进行PDF文件的批量打印
  17. netbackup 备份oracle,Netbackup 6 备份 oracle 9.2
  18. 如何成为一名卓越的软件工程师
  19. 志强CPU E5 E7参数,CPU内核参数对比图
  20. B2B2C多商户商城源码/分销商城/多用户商城系统/商家入驻商城系统

热门文章

  1. Vscode Backspace删除失效
  2. 3025这个数具有一种独特的性质:将它平分为二段,即30和25,使之相加后求平方,即(30+25)2,恰好等于3025本身。请求出具有这样性质的全部四位数
  3. 服务器虚拟内存释放,服务器释放虚拟内存
  4. Android 工具大全下载网址
  5. linux下网卡参数配置,linux网卡配置参数详解!
  6. 淘宝app详情接口,淘宝详情页接口,宝贝详情页接口,商品属性接口,商品信息查询,商品详细信息接口,h5详情
  7. java中跳转页面的两种方法_页面跳转的几种方式
  8. 闲置iMac这样处理更适合
  9. Mac M1 安装Java 开发环境(极其简单的操作)
  10. sqlite3介绍、安装及基本语法