7.6.yum更換國內源linux
自定義yum源:apache
[root@bogon ~]# cd /etc/yum.repos.d [root@bogon 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@bogon yum.repos.d]# rm -f CentOS-Base.repo [root@bogon yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo --2018-06-27 17:41:45-- 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 用時 0s 2018-06-27 17:41:45 (46.7 MB/s) - 已保存 「CentOS7-Base-163.repo」 [1572/1572]) [root@bogon yum.repos.d]# ls CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@bogon yum.repos.d]# vim CentOS7-Base-163.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 "CentOS7-Base-163.repo" 41L, 1572C
其鏡像文件地址更換爲:「baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/」。vim
7.7 yum下載rpm包centos
先恢復以前的yum源。bash
[root@bogon ~]# rm -rf /etc/yum.repos.d
[root@bogon ~]# mv /etc/yum.repos.d_bak /etc/yum.repos.d
yum list
下載RPM包而不安裝的命令以下所示:架構
yum install 包名 -y --downloadonly
下載到指定目錄命令以下所示:app
[root@bogon ~]# yum install 包名 -y --downloadonly --downloaddir=/usr/local/src
下載RPM包到/usr/local/src/目錄下。less
[root@bogon ~]# yum install -y ypbind --downloadonly --downloaddir=/usr/local/src 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.njupt.edu.cn * updates: mirrors.163.com base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 ypbind.x86_64.3.1.37.1-9.el7 將被 安裝 --> 正在處理依賴關係 yp-tools,它被軟件包 3:ypbind-1.37.1-9.el7.x86_64 須要 --> 正在檢查事務 ---> 軟件包 yp-tools.x86_64.0.2.14-5.el7 將被 安裝 --> 解決依賴關係完成 依賴關係解決 =============================================================================================================================================================================================== Package 架構 版本 源 大小 =============================================================================================================================================================================================== 正在安裝: ypbind x86_64 3:1.37.1-9.el7 base 62 k 爲依賴而安裝: yp-tools x86_64 2.14-5.el7 base 79 k 事務概要 =============================================================================================================================================================================================== 安裝 1 軟件包 (+1 依賴軟件包) 總下載量:142 k 安裝大小:299 k Background downloading packages, then exiting: (1/2): yp-tools-2.14-5.el7.x86_64.rpm | 79 kB 00:00:00 (2/2): ypbind-1.37.1-9.el7.x86_64.rpm | 62 kB 00:00:01 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 總計 83 kB/s | 142 kB 00:00:01 exiting because "Download Only" specified
若是包已經安裝了,使用如下命令:ui
[root@bogon ~]# yum reinstall -y bash --downloadonly 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.njupt.edu.cn * updates: mirrors.163.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 bash.x86_64.0.4.2.46-30.el7 將被 已從新安裝 --> 解決依賴關係完成 依賴關係解決 =============================================================================================================================================================================================== Package 架構 版本 源 大小 =============================================================================================================================================================================================== 從新安裝: bash x86_64 4.2.46-30.el7 base 1.0 M 事務概要 =============================================================================================================================================================================================== 從新安裝 1 軟件包 總下載量:1.0 M 安裝大小:3.5 M Background downloading packages, then exiting: bash-4.2.46-30.el7.x86_64.rpm | 1.0 MB 00:00:02 exiting because "Download Only" specified
7.8/7.9 安裝源碼包this
安裝gcc編譯器
[root@bogon ~]# yum install -y gcc 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.njupt.edu.cn * updates: mirrors.163.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 gcc.x86_64.0.4.8.5-28.el7_5.1 將被 安裝 --> 正在處理依賴關係 libgomp = 4.8.5-28.el7_5.1,它被軟件包 gcc-4.8.5-28.el7_5.1.x86_64 須要 --> 正在處理依賴關係 cpp = 4.8.5-28.el7_5.1,它被軟件包 gcc-4.8.5-28.el7_5.1.x86_64 須要 --> 正在處理依賴關係 libgcc >= 4.8.5-28.el7_5.1,它被軟件包 gcc-4.8.5-28.el7_5.1.x86_64 須要 --> 正在處理依賴關係 glibc-devel >= 2.2.90-12,它被軟件包 gcc-4.8.5-28.el7_5.1.x86_64 須要 --> 正在處理依賴關係 libmpc.so.3()(64bit),它被軟件包 gcc-4.8.5-28.el7_5.1.x86_64 須要 --> 正在檢查事務 ---> 軟件包 cpp.x86_64.0.4.8.5-28.el7_5.1 將被 安裝 ---> 軟件包 glibc-devel.x86_64.0.2.17-222.el7 將被 安裝 --> 正在處理依賴關係 glibc-headers = 2.17-222.el7,它被軟件包 glibc-devel-2.17-222.el7.x86_64 須要 --> 正在處理依賴關係 glibc-headers,它被軟件包 glibc-devel-2.17-222.el7.x86_64 須要 ---> 軟件包 libgcc.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟件包 libgcc.x86_64.0.4.8.5-28.el7_5.1 將被 更新 ---> 軟件包 libgomp.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟件包 libgomp.x86_64.0.4.8.5-28.el7_5.1 將被 更新 ---> 軟件包 libmpc.x86_64.0.1.0.1-3.el7 將被 安裝 --> 正在檢查事務 ---> 軟件包 glibc-headers.x86_64.0.2.17-222.el7 將被 安裝 --> 正在處理依賴關係 kernel-headers >= 2.2.1,它被軟件包 glibc-headers-2.17-222.el7.x86_64 須要 --> 正在處理依賴關係 kernel-headers,它被軟件包 glibc-headers-2.17-222.el7.x86_64 須要 --> 正在檢查事務 ---> 軟件包 kernel-headers.x86_64.0.3.10.0-862.3.3.el7 將被 安裝 --> 解決依賴關係完成 依賴關係解決 =============================================================================================================================================================================================== Package 架構 版本 源 大小 =============================================================================================================================================================================================== 正在安裝: gcc x86_64 4.8.5-28.el7_5.1 updates 16 M 爲依賴而安裝: cpp x86_64 4.8.5-28.el7_5.1 updates 5.9 M glibc-devel x86_64 2.17-222.el7 base 1.1 M glibc-headers x86_64 2.17-222.el7 base 678 k kernel-headers x86_64 3.10.0-862.3.3.el7 updates 7.1 M libmpc x86_64 1.0.1-3.el7 base 51 k 爲依賴而更新: libgcc x86_64 4.8.5-28.el7_5.1 updates 101 k libgomp x86_64 4.8.5-28.el7_5.1 updates 156 k 事務概要 =============================================================================================================================================================================================== 安裝 1 軟件包 (+5 依賴軟件包) 升級 ( 2 依賴軟件包) 總下載量:31 M Downloading packages: Not downloading deltainfo for updates, MD is 259 k and rpms are 257 k (1/8): glibc-headers-2.17-222.el7.x86_64.rpm | 678 kB 00:00:11 (2/8): libgcc-4.8.5-28.el7_5.1.x86_64.rpm | 101 kB 00:00:00 (3/8): libgomp-4.8.5-28.el7_5.1.x86_64.rpm | 156 kB 00:00:05 (4/8): libmpc-1.0.1-3.el7.x86_64.rpm | 51 kB 00:00:00 (5/8): kernel-headers-3.10.0-862.3.3.el7.x86_64.rpm | 7.1 MB 00:00:26 (6/8): glibc-devel-2.17-222.el7.x86_64.rpm | 1.1 MB 00:00:39 (7/8): cpp-4.8.5-28.el7_5.1.x86_64.rpm | 5.9 MB 00:00:45 (8/8): gcc-4.8.5-28.el7_5.1.x86_64.rpm | 16 MB 00:01:29 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 總計 357 kB/s | 31 MB 00:01:29 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : libmpc-1.0.1-3.el7.x86_64 1/10 正在安裝 : cpp-4.8.5-28.el7_5.1.x86_64 2/10 正在更新 : libgcc-4.8.5-28.el7_5.1.x86_64 3/10 正在安裝 : kernel-headers-3.10.0-862.3.3.el7.x86_64 4/10 正在安裝 : glibc-headers-2.17-222.el7.x86_64 5/10 正在安裝 : glibc-devel-2.17-222.el7.x86_64 6/10 正在更新 : libgomp-4.8.5-28.el7_5.1.x86_64 7/10 正在安裝 : gcc-4.8.5-28.el7_5.1.x86_64 8/10 清理 : libgcc-4.8.5-28.el7.x86_64 9/10 清理 : libgomp-4.8.5-28.el7.x86_64 10/10 驗證中 : libgomp-4.8.5-28.el7_5.1.x86_64 1/10 驗證中 : kernel-headers-3.10.0-862.3.3.el7.x86_64 2/10 驗證中 : libgcc-4.8.5-28.el7_5.1.x86_64 3/10 驗證中 : gcc-4.8.5-28.el7_5.1.x86_64 4/10 驗證中 : glibc-devel-2.17-222.el7.x86_64 5/10 驗證中 : cpp-4.8.5-28.el7_5.1.x86_64 6/10 驗證中 : glibc-headers-2.17-222.el7.x86_64 7/10 驗證中 : libmpc-1.0.1-3.el7.x86_64 8/10 驗證中 : libgomp-4.8.5-28.el7.x86_64 9/10 驗證中 : libgcc-4.8.5-28.el7.x86_64 10/10 已安裝: gcc.x86_64 0:4.8.5-28.el7_5.1 做爲依賴被安裝: cpp.x86_64 0:4.8.5-28.el7_5.1 glibc-devel.x86_64 0:2.17-222.el7 glibc-headers.x86_64 0:2.17-222.el7 kernel-headers.x86_64 0:3.10.0-862.3.3.el7 libmpc.x86_64 0:1.0.1-3.el7 做爲依賴被升級: libgcc.x86_64 0:4.8.5-28.el7_5.1 libgomp.x86_64 0:4.8.5-28.el7_5.1 完畢!
安裝源碼包一般須要如下3個步驟。
下載源碼包
先切換到 cd /usr/local/src/目錄
[root@bogon src]# wget https://cfhcable.dl.sourceforge.net/project/apachehttpserver/httpd-2.2.27.tar.gz --2018-06-27 13:24:06-- https://cfhcable.dl.sourceforge.net/project/apachehttpserver/httpd-2.2.27.tar.gz 正在解析主機 cfhcable.dl.sourceforge.net (cfhcable.dl.sourceforge.net)... 146.71.73.6 正在鏈接 cfhcable.dl.sourceforge.net (cfhcable.dl.sourceforge.net)|146.71.73.6|:443... 已鏈接。 已發出 HTTP 請求,正在等待迴應... 200 OK 長度:8350426 (8.0M) [application/x-gzip] 正在保存至: 「httpd-2.2.27.tar.gz」 100%[=====================================================================================================================================================>] 8,350,426 56.1KB/s 用時 3m 34s 2018-06-27 13:27:42 (38.1 KB/s) - 已保存 「httpd-2.2.27.tar.gz」 [8350426/8350426])
解壓源碼包
tar -zxvf httpd-2.4.33.tar.gz
配置相關的選項並生成
進入解壓後的源碼目錄,查看可用的配置參數。
cd httpd-2.4.33
./configure --help |less
`configure' configures this package to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print `checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local/apache2] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, `make install' will install all the files in `/usr/local/apache2/bin', `/usr/local/apache2/lib' etc. You can specify an installation prefix other than `/usr/local/apache2' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] :
--prefix=PREFIX,定義軟件包的安裝路徑
--prefix=/usr/local/ apache2 把Apache安裝在/usr/local/apache2目錄下。
返回值是0,說明成功。成功生成Makefile。
[root@bogon httpd-2.4.33]# echo $? 0 [root@bogon httpd-2.4.33]# ls -l Makefile -rw-r--r-- 1 root dip 11110 6月 27 16:39 Makefile
生成Makefile後,須要進行編譯。
make
輸入echo $? 查看結果爲0,進行下一步。
安裝
make install
ls命令查看該目錄。
[root@bogon ~]# ls /usr/local/apache2 bin build-1 include lib