咱们的Linux中默认的yum源是国外的,有的时候网络很差,而我么须要下载的包过大的时候更换成国内的yum源,安装的效率就会提高不少,接下来就讲一下怎么更换yum源。linux
[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源能够忽略这一步。git
[root@localhost yum.repos.d]# rm CentOS-Base.repo rm:是否删除普通文件 "CentOS-Base.repo"?y
[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 6437 0 --:--:-- --:--:-- --:--:-- 6469 [root@localhost yum.repos.d]# ls CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-Vault.repo
[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源已经生效了。apache
有些时候有些包国内的源站不具有,这个时候能够安装一个扩展yum源,扩展源中的包比较全面。yum install -y epel-release 安装完以后可使用yum list | grep epel | more 分屏查看扩展源提供了哪些包vim
[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
当咱们须要一个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 M libaec x86_64 1.0.2-1.el7 epel 33 k libgfortran x86_64 4.8.5-28.el7_5.1 updates 299 k libquadmath 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仍是能够成功的把它下载到指定目录的。cookie
首先要根据本身的实际需求下载源码包 约定:源码包下载到/usr/local/src下 例子:安装Apache网络
[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来指定安装目录 在安装的时候可能会遇到不少种报错app
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... yes setting 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了。 目前在安装过程当中遇到并解决掉的问题就这些。