咱們的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了。 目前在安裝過程當中遇到並解決掉的問題就這些。