7.6 yum更换国内源
安装扩展源epel
yum install -y epel-release
yum list |grep epel
基础源(BASE)
第一步 下载源
[root@test yum.repos.d]# yum install -y wget
[root@test yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2018-10-10 10:50:33-- 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 用时 0.005s
2018-10-10 10:50:33 (311 KB/s) - 已保存 “CentOS7-Base-163.repo” [1572/1572])
[root@test yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
第二步删除或者改名字源来的源,否则会有冲突
[root@test yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.d
清除所有缓存
[root@test yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@test yum.repos.d]# yum list
列出所有仓库
[root@test yum.repos.d]# yum repolist all
扩展源epel
安装扩展源(自带源中没有)
扩展源放置位置
[root@test yum.repos.d]# pwd
/etc/yum.repos.d
安装扩展源
[root@test yum.repos.d]# yum install -y epel-release
[root@test yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-Base.repo.d CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo epel.repo epel-testing.repo
[root@test yum.repos.d]# yum list |grep epel
7.7 yum下载rpm包
yum install -y 包名 --downloadonly
ls /var/cache/yum/x86_64/7/
yum install -y 包名 --downloadonly --downloaddir=路径
yum reinstall -y 包名 --downloadonly --downloaddir=路径
下载网上的rpm包但是不安装(让其他服务器使用)
[root@test yum.repos.d]# yum install zsh --downloadonly
查看rpm包是否被安装
[root@test yum.repos.d]# rpm -q zsh
未安装软件包 zsh
下载的位置(确定位置查看下载上图中的源)
[root@test yum.repos.d]# ls /var/cache/yum/x86_64/7/base/packages/
zsh-5.0.2-28.el7.x86_64.rpm
仓库所在位置
[root@test yum.repos.d]# ls /var/cache/yum/x86_64/7/
base C7.0.1406-centosplus C7.1.1503-base C7.1.1503-updates C7.2.1511-fasttrack C7.3.1611-extras C7.4.1708-centosplus c7-media epel timedhosts
base-debuginfo C7.0.1406-extras C7.1.1503-centosplus C7.2.1511-base C7.2.1511-updates C7.3.1611-fasttrack C7.4.1708-extras centosplus extras timedhosts.txt
base-source C7.0.1406-fasttrack C7.1.1503-extras C7.2.1511-centosplus C7.3.1611-base C7.3.1611-updates C7.4.1708-fasttrack centosplus-source extras-source updates
C7.0.1406-base C7.0.1406-updates C7.1.1503-fasttrack C7.2.1511-extras C7.3.1611-centosplus C7.4.1708-base C7.4.1708-updates cr fasttrack updates-source
指定rpm包下载的位置
[root@test yum.repos.d]# yum install zsh --downloadonly --downloaddir=/tmp/
下载一个已经安装过的包
[root@test yum.repos.d]# yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
7.8/7.9 源码包安装
下载源码包的目录
[root@test src]# pwd
/usr/local/src
下载Apache源码包过程
[root@test src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.34.tar.gz
[root@test src]# ls
httpd-2.4.34.tar.gz
[root@test src]# tar zxvf httpd-2.4.34.tar.gz
[root@test src]# ls
httpd-2.4.34 httpd-2.4.34.tar.gz
[root@test src]# cd httpd-2.4.34
[root@test httpd-2.4.34]# ls
ABOUT_APACHE build config.layout httpd.dsp LAYOUT Makefile.win README.cmake test
acinclude.m4 BuildAll.dsp configure httpd.mak libhttpd.dep modules README.platforms VERSIONING
Apache-apr2.dsw BuildBin.dsp configure.in httpd.spec libhttpd.dsp NOTICE ROADMAP
Apache.dsw buildconf docs include libhttpd.mak NWGNUmakefile server
apache_probes.d CHANGES emacs-style INSTALL LICENSE os srclib
ap.d CMakeLists.txt httpd.dep InstallBin.dsp Makefile.in README support
安装时查看安装文档: INSTALL
[root@test httpd-2.4.34]# more INSTALL
安装
[root@test httpd-2.4.34]# ./configure --prefix=/usr/local/apache2
问题一
查看上一条命令运行过程是否有报错
[root@test src]# echo $?
解决问题
[root@test src]# wget https://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz (下载时没有许可证)
--2018-10-10 11:40:23-- https://mirrors.cnnic.cn/apache/apr/apr-1.6.5.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|:443... 已连接。
错误: 无法验证 mirrors.cnnic.cn 的由 “/C=CN/O=TrustAsia Technologies, Inc./OU=Symantec Trust Network/OU=Domain Validated SSL/CN=TrustAsia DV SSL CA - G5” 颁发的证书:
颁发的证书已经过期。
要以不安全的方式连接至 mirrors.cnnic.cn,使用“--no-check-certificate”。
解决许可证方法
[root@test src]# wget https://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz --no-check-certificate
--2018-10-10 11:47:18-- https://mirrors.cnnic.cn/apache/apr/apr-1.6.5.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|:443... 已连接。
警告: 无法验证 mirrors.cnnic.cn 的由 “/C=CN/O=TrustAsia Technologies, Inc./OU=Symantec Trust Network/OU=Domain Validated SSL/CN=TrustAsia DV SSL CA - G5” 颁发的证书:
颁发的证书已经过期。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1073556 (1.0M) [application/x-gzip]
正在保存至: “apr-1.6.5.tar.gz”
100%[=========================================================================================>] 1,073,556 4.85MB/s 用时 0.2s
2018-10-10 11:47:20 (4.85 MB/s) - 已保存 “apr-1.6.5.tar.gz” [1073556/1073556])
[root@test src]# wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
--2018-10-10 11:49:15-- http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.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
长度:554301 (541K) [application/x-gzip]
正在保存至: “apr-util-1.6.1.tar.gz”
100%[=========================================================================================>] 554,301 3.01MB/s 用时 0.2s
2018-10-10 11:49:21 (3.01 MB/s) - 已保存 “apr-util-1.6.1.tar.gz” [554301/554301])
[root@test src]# ls
apr-1.6.5.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.34 httpd-2.4.34.tar.gz
[root@test src]# tar -zxvf apr-1.6.5.tar.gz
[root@test src]# tar -zxvf apr-util-1.6.1.tar.gz
[root@test httpd-2.4.34]# cp -r ../apr-1.6.5 srclib/apr
[root@test httpd-2.4.34]# cp -r ../apr-util-1.6.1 srclib/apr-util
[root@test srclib]# cd apr
[root@test apr]# ./configure --prefix=/usr/local/apr
[root@test apr]# echo $?
0
[root@test apr]# make
[root@test apr]# echo $?
0
[root@test apr]# make install
[root@test apr]# echo $?
0
[root@test srclib]# cd apr-util/
[root@test httpd-2.4.34]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
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... reconfig
configure: error: Cannot use an external APR with the bundled APR-util
[root@test apr-util]# echo $?
0
[root@test apr-util]# make
make[1]: 进入目录“/usr/local/src/httpd-2.4.34/srclib/apr-util”
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/usr/local/src/httpd-2.4.34/srclib/apr-util/include -I/usr/local/src/httpd-2.4.34/srclib/apr-util/include/private -I/usr/local/apr/include/apr-1 -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录
#include <expat.h>
^
编译中断。
make[1]: *** [xml/apr_xml.lo] 错误 1
make[1]: 离开目录“/usr/local/src/httpd-2.4.34/srclib/apr-util”
make: *** [all-recursive] 错误 1
缺少 expat库
[root@test apr-util]# yum install expat-devel
[root@test apr-util]# echo $?
0
[root@test apr-util]# make install
[root@test apr-util]# echo $?
0
[root@test httpd-2.4.34]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
问题二
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@test httpd-2.4.34]# echo $?
1
解决问题:
[root@test httpd-2.4.34]# yum install pcre pcre-devel -y
[root@test httpd-2.4.34]# echo $?
0
[root@test httpd-2.4.34]# make
问题三
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] 错误 1
make[2]: 离开目录“/usr/local/src/httpd-2.4.34/support”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/httpd-2.4.34/support”
make: *** [all-recursive] 错误 1
[root@test httpd-2.4.34]# echo $?
2
重新编译:
[root@test httpd-2.4.34]# ./configure --prefix=/usr/local/apache2 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
报错:
checking for zlib location... not found
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
解决:
[root@test httpd-2.4.34]# yum list |grep zlib
[root@test httpd-2.4.34]# yum install -y zlib-devel
[root@test httpd-2.4.34]# echo $?
0
[root@test httpd-2.4.34]# make
问题依然未解决
重新编译(问题解决)
[root@test httpd-2.4.34]#./configure --prefix=/usr/local/apache2 --enable-so --enable-mpms-shared=all --with-mpm=event --enable-mods-shared=most --with-included-apr --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@test httpd-2.4.34]# echo $?
0
[root@test httpd-2.4.34]# make
[root@test httpd-2.4.34]# echo $?
0
[root@test httpd-2.4.34]# make install
[root@test httpd-2.4.34]# echo $?
0
安装完毕
[root@test httpd-2.4.34]# ls /usr/local/apache2/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules