2019獨角獸企業重金招聘Python工程師標準>>>
7.6.yum更換國內源
自定義yum源:
[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/”。
7.7 yum下載rpm包
先恢復之前的yum源。
[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
下載到指定目錄命令如下所示:
[root@bogon ~]# yum install 包名 -y --downloadonly --downloaddir=/usr/local/src
下載RPM包到/usr/local/src/目錄下。
[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
如果包已經安裝了,使用以下命令:
[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 安裝源碼包
安裝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 Mglibc-devel x86_64 2.17-222.el7 base 1.1 Mglibc-headers x86_64 2.17-222.el7 base 678 kkernel-headers x86_64 3.10.0-862.3.3.el7 updates 7.1 Mlibmpc x86_64 1.0.1-3.el7 base 51 k
為依賴而更新:libgcc x86_64 4.8.5-28.el7_5.1 updates 101 klibgomp 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個步驟。
- .configure。這一步可以定制功能,加上相應的選項即可。可以通過./configure --help來查看。這一步會自動檢測你的linux系統與相關的套件是否有編譯改源碼包時所需要的庫,因為一旦缺少某個庫,就不能完成編譯了。只有通過檢測后,才會生成Makefile文件。
- make。會根據Makefile文件中預設的參數進行編譯,這一步就是gcc在工作了。
- make install。這一步是安裝步驟,用于創建相關軟件的存放目錄和配置文件。
下載源碼包
先切換到 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
?