文章目录
一、实验环境
rpm包制作的实验环境:
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.10 (Final)
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-754.el6.x86_64 #1 SMP Tue Jun 19 21:26:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# ifconfig | sed -rn 's/^[[:space:]]+inet addr:(.*)[[:space:]]+Bcast.*$/\1/p'
192.168.56.98
实验安装我们制作的rpm的环境:
[root@localhost opt]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@localhost opt]# uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost opt]# ifconfig | sed -rn 's/^[[:space:]]+inet addr:(.*)[[:space:]]+Bcast.*$/\1/p'
192.168.56.96
二、去官网下载源代码包
1、apache的apr项目的官方站点:
http://apr.apache.org/
2、apr、apr-util以及apr-iconv的源码下载链接:
http://apr.apache.org/download.cgi
3、apache的httpd项目的官方站点
http://httpd.apache.org/
4、httpd2.4 的源码下载链接:
http://httpd.apache.org/download.cgi#apache24
5、apr、apr-util以及apr-iconv和httpd的关系简析:
参考摘抄链接:
https://www.cnblogs.com/Alight/p/3997777.html
apr:APR is the base portability library.
APR是一个基本的可一直运行库。主要为上层的应用程序提供一个可以跨越多操作系统平台使用的
底层支持接口库。在早期 的Apache版本中,应用程序本身必须能够处理各种具体操作系统平台的
细节,并针对不同的平台调用不同的处理函数。随着Apache的进一步开 发,Apache组织决定将这些
通用的函数独立出来并发展成为一个新的项目。
apr中包含了一些通用的开发组件,包括mmap,DSO等等。
apr-utils:APR-util provides a number of helpful abstractions on top of APR.
APR-util在ARP的基础之上,抽象出来的。也是为了辅助apache工作的。
APR-util提供的目录中也是包含了一些常用的开发组件。这些组件与apr目录下的相比,
它们与apache的关系更加密切一些。比如存储段和存储段组,加密等等。
apr-iconv:APR-iconv provides a portable iconv() implementation built on top of APR.
It is generally of interest only where no system provided iconv() is available (either in libiconv,
or libc as applicable). An example is the Windows platform, where APR-iconv is required to
enable the APR-util library's apr_xlate feature.
包中的文件主要用于实现iconv编码。目前的大部分编码转换过程都是与本地编码相关的。
在进行转换之前必须能够正确地设置本地编码。因此假如两个非本地编码A和B需要转换,
则转换过程大致为A->Local以及Local->B或者B->Local以及Local->A。
6、下载好的源代码存放说明(要是bzip2压缩格式的tar包)
[root@localhost ~]# cd /opt/
[root@localhost opt]# mkdir httpd_software #创建源代码存放目录
[root@localhost opt]# cd httpd_software/
[root@localhost httpd_software]# ls
[root@localhost httpd_software]# ls #上传后再查看
apr-1.6.5.tar.bz2 apr-iconv-1.2.2.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.37.tar.bz2
[root@localhost httpd_software]# file *.tar.bz2
apr-1.6.5.tar.bz2: bzip2 compressed data, block size = 900k
apr-iconv-1.2.2.tar.bz2: bzip2 compressed data, block size = 900k
apr-util-1.6.1.tar.bz2: bzip2 compressed data, block size = 900k
httpd-2.4.37.tar.bz2: bzip2 compressed data, block size = 900k
三、安装开发包组
(1) CentOS 6.x安装开发包组
安装开发包组为这两个:"Development tools" "Server Platform Development"
(2) 查看要安装的开发包组
yum groupinfo "Development tools"
yum groupinfo "Server Platform Development"
yum groupinfo "Server Platform"
上面省略一下内容......
Group: Development tools
Description: A basic development environment.
Mandatory Packages: #强制安装的软件包(开发包组安装的化,默认这些必须要装上)
autoconf
automake
binutils
bison
flex
gcc
gcc-c++
gettext
libtool
make
patch
pkgconfig
redhat-rpm-config
rpm-build
Default Packages: #默认软件包
byacc
cscope
ctags
cvs
diffstat
doxygen
elfutils
gcc-gfortran
git
indent
intltool
patchutils
rcs
subversion
swig
systemtap
Optional Packages: #可选软件包
ElectricFence
PyYAML
ant
babel
bzr
chrpath
cmake
compat-gcc-34
compat-gcc-34-c++
compat-gcc-34-g77
cvs-inetd
dejagnu
expect
gcc-gnat
gcc-java
gcc-objc
gcc-objc++
imake
jpackage-utils
kdewebdev
ksc
libstdc++-docs
mercurial
mod_dav_svn
nasm
perltidy
python-docs
python-requests
python-six
rpmdevtools
rpmlint
systemtap-sdt-devel
systemtap-server
[root@localhost httpd_software]# yum groupinfo "Server Platform Development"
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
Group: Server Platform Development
Description: Development headers and libraries for developing applications to run on the CentOS Linux Server Platform.
Mandatory Packages: #这个开发包组主要是一些库的头文件。(不全)
db4-devel
dbus-devel
glibc-devel
krb5-devel
libstdc++-devel
libvirt-devel
libvirt-java-devel
ncurses-devel
nss-devel
openldap-devel
openssl-devel
pam-devel
zlib-devel
[root@localhost ~]# yum groupinfo "Server Platform"
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
Group: Server Platform
Description: Supported libraries for the CentOS Linux Server Platform.
Mandatory Packages: #这个包组包括一些支持的库
db4
dbus-libs
glibc
krb5-libs
libgcc
libstdc++
ncurses-libs
nss
openldap
openssl
pam
redhat-lsb
zlib
Optional Packages:
libatomic
libcilkrts
libitm
libmpx
汇总安装为:
yum groupinstall "Development tools" "Server Platform Development" "Server Platform"
配置epel源:(为了让安装更快,我配置一个epel源)
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
安装rpm制作相关的工具包:
yum install rpm-build rpmdevtools
安装过程省略,因为比较长,看懂上面的解释后,直接安装即可。
四、利用源代码的tar.bz2格式的包制作rpm包
4.1、为什么制作rpm包说明
(1) rpmbuild命令的简要帮助信息
[root@localhost httpd_software]# rpmbuild --help
Usage: rpmbuild [OPTION...]
--quiet
Build options with [ <specfile> | <tarball> | <source package> ]:
-bp build through %prep (unpack sources and apply patches) from <specfile>
-bc build through %build (%prep, then compile) from <specfile>
-bi build through %install (%prep, %build, then install) from <specfile>
-bl verify %files section from <specfile>
-ba build source and binary packages from <specfile>
-bb build binary package only from <specfile>
-bs build source package only from <specfile>
-tp build through %prep (unpack sources and apply patches) from <tarball>
-tc build through %build (%prep, then compile) from <tarball>
-ti build through %install (%prep, %build, then install) from <tarball>
-ta build source and binary packages from <tarball>
#这个是我们一会儿要用的选项。从tarball包中构建二进制包(rpm包)
-tb build binary package only from <tarball>
-ts build source package only from <tarball>
--rebuild build binary package from <source package>
--recompile build through %install (%prep, %build, then install) from <source package>
--buildroot=DIRECTORY override build root
--clean remove build tree when done
--nobuild do not execute any stages of the build
--nodeps do not verify build dependencies
--nodirtokens generate package header(s) compatible with (legacy) rpm[23] packaging
--rmsource remove sources when done
--rmspec remove specfile when done
--short-circuit skip straight to specified stage (only for c,i)
--target=CPU-VENDOR-OS override target platform
Common options for all rpm modes and executables:
-D, --define='MACRO EXPR' define MACRO with value EXPR
-E, --eval='EXPR' print macro expansion of EXPR
--macros=<FILE:...> read <FILE:...> instead of default file(s)
--nodigest don't verify package digest(s)
--nosignature don't verify package signature(s)
--rcfile=<FILE:...> read <FILE:...> instead of default file(s)
-r, --root=ROOT use ROOT as top level directory (default: "/")
--querytags display known query tags
--showrc display final rpmrc and macro configuration
--quiet provide less detailed output
-v, --verbose provide more detailed output
--version print the version of rpm being used
Options implemented via popt alias/exec:
--dbpath=DIRECTORY use database in DIRECTORY
--with=<option> enable configure <option> for build
--without=<option> disable configure <option> for build
--buildpolicy=<policy> set buildroot <policy> (e.g. compress man pages)
Help options:
-?, --help Show this help message
--usage Display brief usage message
#因为从specfile制作语法过于复杂,我们这里直接使用从tarball包中制作。
(2) 先测试一下httpd2.4版本的包制作需要的依赖有哪些
扫描二维码关注公众号,回复:
4959700 查看本文章
[root@localhost httpd_software]# rpmbuild -tb httpd-2.4.37.tar.bz2
error: Failed build dependencies:
libuuid-devel is needed by httpd-2.4.37-1.x86_64
apr-devel >= 1.4.0 is needed by httpd-2.4.37-1.x86_64
apr-util-devel >= 1.4.0 is needed by httpd-2.4.37-1.x86_64
pcre-devel >= 5.0 is needed by httpd-2.4.37-1.x86_64
lua-devel is needed by httpd-2.4.37-1.x86_64
libxml2-devel is needed by httpd-2.4.37-1.x86_64
构建httpd2.4版本的rpm包还需要:
libuuid-devel这个库头文件,apr-devel要大于等于1.4.0版本,apr-util-devel要大于等于1.4.0版本
pcre-devel要大于等于5.0版本,lua-devel这个库头文件,libxml2-devel这个库头文件。
我们来看看现在yum仓库提供的这些软件版本符合不符合:
[root@localhost httpd_software]# yum list |grep -E '^libuuid-devel|^apr-devel|^apr-util-devel|^pcre-devel|^lua-devel|^libxml2-devel'
apr-devel.i686 1.3.9-5.el6_9.1 base
apr-devel.x86_64 1.3.9-5.el6_9.1 base
apr-util-devel.i686 1.3.9-3.el6_0.1 base
apr-util-devel.x86_64 1.3.9-3.el6_0.1 base
libuuid-devel.i686 2.17.2-12.28.el6_9.2 base
libuuid-devel.x86_64 2.17.2-12.28.el6_9.2 base
libxml2-devel.i686 2.7.6-21.el6_8.1 base
libxml2-devel.x86_64 2.7.6-21.el6_8.1 base
lua-devel.i686 5.1.4-4.1.el6 base
lua-devel.x86_64 5.1.4-4.1.el6 base
pcre-devel.i686 7.8-7.el6 base
pcre-devel.x86_64 7.8-7.el6 base
结论:只有apr-devel和apr-util-devel版本不符合,而且这也是为什么CentOS6.x一直是httpd2.2的缘故,因为
httpd2.4版本需要的是apr和apr-util版本要大于1.4.0,而base仓库提供的是1.3.9版本的。
4.2、apr源代码制作rpm包
(1) 先看看制作apr有什么依赖问题没有
[root@localhost httpd_software]# rpmbuild -tb apr-1.6.5.tar.bz2
error: Failed build dependencies:
libuuid-devel is needed by apr-1.6.5-1.x86_64
(2) 安装libuuid-devel后再重新制作
yum install libuuid-devel
rpmbuild -tb apr-1.6.5.tar.bz2
制作如果没有报错,那么RPM包默认路径:(我是root用户操作的,所以在家目录下会创建rpmbuild目录)
/root/rpmbuild/RPMS/x86_64
[root@localhost httpd_software]# ls /root/rpmbuild/RPMS/x86_64/
apr-1.6.5-1.x86_64.rpm apr-debuginfo-1.6.5-1.x86_64.rpm apr-devel-1.6.5-1.x86_64.rpm
#可以看到制作出了3个软件包,生产中用的就是apr和apr-devel这两个,可以看到apr-devel版本符合
大于等于1.4.0版本了。那个apr-debuginfo是与调试相关的,可以不用。
4.3、apr-util源代码制作rpm包
(1) 先看看制作apr-util有什么依赖问题没有
[root@localhost httpd_software]# rpmbuild -tb apr-util-1.6.1.tar.bz2
error: Failed build dependencies:
apr-devel >= 1.4.0 is needed by apr-util-1.6.1-1.x86_64
expat-devel is needed by apr-util-1.6.1-1.x86_64
postgresql-devel is needed by apr-util-1.6.1-1.x86_64
mysql-devel is needed by apr-util-1.6.1-1.x86_64
sqlite-devel >= 3.0.0 is needed by apr-util-1.6.1-1.x86_64
unixODBC-devel is needed by apr-util-1.6.1-1.x86_64
#这里依赖可多来,要先安装我们之前制作好的大于等于1.4.0版本的apr-devel。
然后是一些库头文件,我们直接yum安装即可,那个sqlite-devel,默认base仓库版本符合。
yum install expat-devel postgresql-devel mysql-devel sqlite-devel unixODBC-devel
安装我们之前制作的apr-devel的rpm包:
[root@localhost httpd_software]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-devel-1.6.5-1.x86_64.rpm
error: Failed dependencies:
apr = 1.6.5 is needed by apr-devel-1.6.5-1.x86_64
[root@localhost httpd_software]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-1.6.5-1.x86_64.rpm
Preparing... ########################################### [100%]
1:apr ########################################### [100%]
[root@localhost httpd_software]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-devel-1.6.5-1.x86_64.rpm
Preparing... ########################################### [100%]
1:apr-devel ########################################### [100%]
注意点1:我们要使用升级安装,因为可能系统存在低版本的apr和apr-devel(1.3.9版本的);
注意点2:我们在安装自己制作的apr-devel的时候,要看看是否有依赖问题,apr-devel要依赖于apr,所以
要先安装apr(要注意版本的对应)
检测安装后的版本:
[root@localhost httpd_software]# rpm -qa|grep apr
apr-util-1.3.9-3.el6_0.1.x86_64 #这个是base仓库低版本的
apr-devel-1.6.5-1.x86_64 #这个符合
apr-1.6.5-1.x86_64 #这个符合
(2) 重新制作apr-util
rpmbuild -tb apr-util-1.6.1.tar.bz2
PS:过程比较长,就省略了
(3) 查看制作的rpm包
[root@localhost httpd_software]# ls -l /root/rpmbuild/RPMS/x86_64/
total 2520
-rw-r--r--. 1 root root 98824 Dec 1 17:45 apr-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 438508 Dec 1 17:45 apr-debuginfo-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 892132 Dec 1 17:45 apr-devel-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 83408 Dec 1 17:57 apr-util-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 7084 Dec 1 17:57 apr-util-dbm-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 446464 Dec 1 17:57 apr-util-debuginfo-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 490012 Dec 1 17:57 apr-util-devel-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 9024 Dec 1 17:57 apr-util-ldap-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14912 Dec 1 17:57 apr-util-mysql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 12420 Dec 1 17:57 apr-util-nss-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 20592 Dec 1 17:57 apr-util-odbc-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 10844 Dec 1 17:57 apr-util-openssl-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14804 Dec 1 17:57 apr-util-pgsql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 11360 Dec 1 17:57 apr-util-sqlite-1.6.1-1.x86_64.rpm
#可以看到与apr-util相关的子包很多。基本上都是数据库的,有DBM驱动,LDAP,mysql驱动,还有 Mozilla NSS的加密方面的,ODBC驱动,PostgreSQL驱动,SQLite驱动,OpenSSL加密相关。
4.4、apr-iconv源代码制作rpm包
(1) 先看看制作apr-iconv有什么依赖问题没有
[root@localhost httpd_software]# rpmbuild -tb apr-iconv-1.2.2.tar.bz2
error: Failed to read spec file from apr-iconv-1.2.2.tar.bz2
[root@localhost httpd_software]# rpmbuild -tb apr-iconv-1.2.2.tar.gz
error: Failed to read spec file from apr-iconv-1.2.2.tar.gz
#发现有报错,然后没找到spec文件,可能这个软件包因为不是安装httpd2.4必须,所以没有提供spec。
(2) 解压开来看看与其他源代码包的区别,顺便看看说明文档
[root@localhost httpd_software]# ls -l apr-1.6.5/*.spec
-rw-r--r--. 1 1001 1001 2558 Sep 11 05:14 apr-1.6.5/apr.spec
[root@localhost httpd_software]# ls -l apr-iconv-1.2.2/*.spec
ls: cannot access apr-iconv-1.2.2/*.spec: No such file or directory
#果然这个软件包没有提供spec文件,那么我们就不管这个软件包了。如果实在要,我们可以编译
安装。而且我们之前有检测过,httpd2.4版本好像默认依赖包中不包含这个软件包。
4.5、httpd源代码制作rpm包
(1) 先看看制作httpd的rpm有什么依赖问题没有
[root@localhost httpd_software]# rpmbuild -tb httpd-2.4.37.tar.bz2
error: Failed build dependencies:
apr-util-devel >= 1.4.0 is needed by httpd-2.4.37-1.x86_64
pcre-devel >= 5.0 is needed by httpd-2.4.37-1.x86_64
lua-devel is needed by httpd-2.4.37-1.x86_64
libxml2-devel is needed by httpd-2.4.37-1.x86_64
(2) 解决依赖
yum install pcre-devel lua-devel libxml2-devel
拷贝与apr-util相关的所有包到一个目录,利用yum包安装所有的rpm后缀的,自动让它解决依赖关系
[root@localhost httpd_software]# mkdir /tmp/apr-util-rpm
[root@localhost httpd_software]# cd /tmp/apr-util-rpm
[root@localhost apr-util-rpm]# cp -a /root/rpmbuild/RPMS/x86_64/apr-util-*.rpm .
[root@localhost apr-util-rpm]# ls
apr-util-1.6.1-1.x86_64.rpm apr-util-devel-1.6.1-1.x86_64.rpm apr-util-nss-1.6.1-1.x86_64.rpm apr-util-pgsql-1.6.1-1.x86_64.rpm
apr-util-dbm-1.6.1-1.x86_64.rpm apr-util-ldap-1.6.1-1.x86_64.rpm apr-util-odbc-1.6.1-1.x86_64.rpm apr-util-sqlite-1.6.1-1.x86_64.rpm
apr-util-debuginfo-1.6.1-1.x86_64.rpm apr-util-mysql-1.6.1-1.x86_64.rpm apr-util-openssl-1.6.1-1.x86_64.rpm
[root@localhost apr-util-rpm]# rm -f apr-util-debuginfo-1.6.1-1.x86_64.rpm #删掉那个调试的包
[root@localhost apr-util-rpm]# yum install *.rpm
检查:
[root@localhost apr-util-rpm]# rpm -qa|grep apr
apr-util-mysql-1.6.1-1.x86_64
apr-util-devel-1.6.1-1.x86_64
apr-util-nss-1.6.1-1.x86_64
apr-devel-1.6.5-1.x86_64
apr-util-1.6.1-1.x86_64
apr-util-ldap-1.6.1-1.x86_64
apr-util-openssl-1.6.1-1.x86_64
apr-util-dbm-1.6.1-1.x86_64
apr-util-sqlite-1.6.1-1.x86_64
apr-1.6.5-1.x86_64
apr-util-pgsql-1.6.1-1.x86_64
apr-util-odbc-1.6.1-1.x86_64
(3) 再次制作httpd2.4的rpm包
[root@localhost apr-util-rpm]# cd /opt/httpd_software/
[root@localhost httpd_software]# rpmbuild -tb httpd-2.4.37.tar.bz2
制作过程很长,省略了。
(4) rpm包查看
[root@localhost httpd_software]# ls -l /root/rpmbuild/RPMS/x86_64/
total 12212
-rw-r--r--. 1 root root 98824 Dec 1 17:45 apr-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 438508 Dec 1 17:45 apr-debuginfo-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 892132 Dec 1 17:45 apr-devel-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 83408 Dec 1 17:57 apr-util-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 7084 Dec 1 17:57 apr-util-dbm-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 446464 Dec 1 17:57 apr-util-debuginfo-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 490012 Dec 1 17:57 apr-util-devel-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 9024 Dec 1 17:57 apr-util-ldap-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14912 Dec 1 17:57 apr-util-mysql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 12420 Dec 1 17:57 apr-util-nss-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 20592 Dec 1 17:57 apr-util-odbc-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 10844 Dec 1 17:57 apr-util-openssl-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14804 Dec 1 17:57 apr-util-pgsql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 11360 Dec 1 17:57 apr-util-sqlite-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 1260500 Dec 1 18:19 httpd-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 3646060 Dec 1 18:19 httpd-debuginfo-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 199852 Dec 1 18:19 httpd-devel-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 4533472 Dec 1 18:19 httpd-manual-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 72248 Dec 1 18:19 httpd-tools-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 44660 Dec 1 18:19 mod_authnz_ldap-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 44076 Dec 1 18:19 mod_lua-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 22964 Dec 1 18:19 mod_proxy_html-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 89992 Dec 1 18:19 mod_ssl-2.4.37-1.x86_64.rpm
#上面可以看到有httpd相关的包了,还有mod相关的包
我们把这些rpm保存到一个预建的目录,然后去掉不需要的调试相关的,打包好来以备后边我们测试使用
[root@localhost httpd_software]# mkdir /var/tmp/http_all_rpms
[root@localhost httpd_software]# cd /var/tmp/http_all_rpms
[root@localhost http_all_rpms]# cp -a /root/rpmbuild/RPMS/x86_64/*.rpm .
[root@localhost http_all_rpms]# rm -f apr-debuginfo-1.6.5-1.x86_64.rpm apr-util-debuginfo-1.6.1-1.x86_64.rpm httpd-debuginfo-2.4.37-1.x86_64.rpm
[root@localhost http_all_rpms]# ls *.rpm
apr-1.6.5-1.x86_64.rpm apr-util-ldap-1.6.1-1.x86_64.rpm apr-util-pgsql-1.6.1-1.x86_64.rpm httpd-tools-2.4.37-1.x86_64.rpm
apr-devel-1.6.5-1.x86_64.rpm apr-util-mysql-1.6.1-1.x86_64.rpm apr-util-sqlite-1.6.1-1.x86_64.rpm mod_authnz_ldap-2.4.37-1.x86_64.rpm
apr-util-1.6.1-1.x86_64.rpm apr-util-nss-1.6.1-1.x86_64.rpm httpd-2.4.37-1.x86_64.rpm mod_lua-2.4.37-1.x86_64.rpm
apr-util-dbm-1.6.1-1.x86_64.rpm apr-util-odbc-1.6.1-1.x86_64.rpm httpd-devel-2.4.37-1.x86_64.rpm mod_proxy_html-2.4.37-1.x86_64.rpm
apr-util-devel-1.6.1-1.x86_64.rpm apr-util-openssl-1.6.1-1.x86_64.rpm httpd-manual-2.4.37-1.x86_64.rpm mod_ssl-2.4.37-1.x86_64.rpm
[root@localhost http_all_rpms]# cd ../
[root@localhost tmp]# tar -Jcvf http_all_rpms.tar.xz http_all_rpms/
http_all_rpms/
http_all_rpms/mod_lua-2.4.37-1.x86_64.rpm
http_all_rpms/mod_authnz_ldap-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-tools-2.4.37-1.x86_64.rpm
http_all_rpms/mod_ssl-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-devel-1.6.1-1.x86_64.rpm
http_all_rpms/apr-1.6.5-1.x86_64.rpm
http_all_rpms/apr-util-nss-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-2.4.37-1.x86_64.rpm
http_all_rpms/mod_proxy_html-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-ldap-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-dbm-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-manual-2.4.37-1.x86_64.rpm
http_all_rpms/apr-devel-1.6.5-1.x86_64.rpm
http_all_rpms/apr-util-pgsql-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-sqlite-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-mysql-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-devel-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-openssl-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-odbc-1.6.1-1.x86_64.rpm
[root@localhost tmp]# ls -l http_all_rpms.tar.xz
-rw-r--r--. 1 root root 7643536 Dec 1 18:22 http_all_rpms.tar.xz
4.6、选一台最小化安装的新服务使用我们制作的rpm包
[root@localhost opt]# ls
http_all_rpms http_all_rpms.tar.xz
[root@localhost opt]# ls -l http_all_rpms
total 7780
-rw-r--r-- 1 root root 98824 Dec 1 17:45 apr-1.6.5-1.x86_64.rpm
-rw-r--r-- 1 root root 892132 Dec 1 17:45 apr-devel-1.6.5-1.x86_64.rpm
-rw-r--r-- 1 root root 83408 Dec 1 17:57 apr-util-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 7084 Dec 1 17:57 apr-util-dbm-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 490012 Dec 1 17:57 apr-util-devel-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 9024 Dec 1 17:57 apr-util-ldap-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 14912 Dec 1 17:57 apr-util-mysql-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 12420 Dec 1 17:57 apr-util-nss-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 20592 Dec 1 17:57 apr-util-odbc-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 10844 Dec 1 17:57 apr-util-openssl-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 14804 Dec 1 17:57 apr-util-pgsql-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 11360 Dec 1 17:57 apr-util-sqlite-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 1260500 Dec 1 18:19 httpd-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 199852 Dec 1 18:19 httpd-devel-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 4533472 Dec 1 18:19 httpd-manual-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 72248 Dec 1 18:19 httpd-tools-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 44660 Dec 1 18:19 mod_authnz_ldap-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 44076 Dec 1 18:19 mod_lua-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 22964 Dec 1 18:19 mod_proxy_html-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 89992 Dec 1 18:19 mod_ssl-2.4.37-1.x86_64.rpm
[root@localhost opt]# pwd
/opt
[root@localhost opt]# cd http_all_rpms
[root@localhost http_all_rpms]# yum install *.rpm
安装过程省略,查看安装后的软件包:
[root@localhost http_all_rpms]# rpm -qa|grep httpd
httpd-2.4.37-1.x86_64
httpd-manual-2.4.37-1.x86_64
httpd-tools-2.4.37-1.x86_64
httpd-devel-2.4.37-1.x86_64
[root@localhost http_all_rpms]# rpm -qa|grep apr
apr-util-mysql-1.6.1-1.x86_64
apr-util-dbm-1.6.1-1.x86_64
apr-util-nss-1.6.1-1.x86_64
apr-1.6.5-1.x86_64
apr-util-ldap-1.6.1-1.x86_64
apr-util-devel-1.6.1-1.x86_64
apr-util-odbc-1.6.1-1.x86_64
apr-util-sqlite-1.6.1-1.x86_64
apr-util-openssl-1.6.1-1.x86_64
apr-util-1.6.1-1.x86_64
apr-devel-1.6.5-1.x86_64
apr-util-pgsql-1.6.1-1.x86_64
#操作启动httpd事宜,然后启动,访问测试
[root@localhost http_all_rpms]# id apache
uid=48(apache) gid=48(apache) groups=48(apache)
[root@localhost http_all_rpms]# chkconfig --list|grep httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost http_all_rpms]# service httpd status
httpd is stopped
[root@localhost http_all_rpms]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost http_all_rpms]#
[root@localhost http_all_rpms]# service httpd configtest
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
vim /etc/httpd/conf/httpd.conf
添加一行:
ServerName www.yanhui.com
向/etc/hosts中加入一条记录:
[root@localhost http_all_rpms]# echo "192.168.56.96 www.yanhui.com" >> /etc/hosts
[root@localhost http_all_rpms]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.96 www.yanhui.com
[root@localhost http_all_rpms]# service httpd configtest
Syntax OK
[root@localhost http_all_rpms]# service httpd start
Starting httpd: [ OK ]
[root@localhost http_all_rpms]# ss -nltu
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 :::80 :::*
tcp LISTEN 0 128 :::22 :::*
tcp LISTEN 0 128 *:22 *:*
tcp LISTEN 0 100 ::1:25 :::*
tcp LISTEN 0 100 127.0.0.1:25 *:*
[root@localhost http_all_rpms]# ps aux|grep httpd
root 1396 0.0 0.2 78636 2236 ? Ss 18:53 0:00 /usr/sbin/httpd
daemon 1398 0.0 0.4 422896 4208 ? Sl 18:53 0:00 /usr/sbin/httpd
daemon 1426 0.0 0.4 422896 4212 ? Sl 18:53 0:00 /usr/sbin/httpd
daemon 1427 0.0 0.4 422896 4208 ? Sl 18:53 0:00 /usr/sbin/httpd
root 1488 0.0 0.0 103260 876 pts/0 S+ 18:53 0:00 grep httpd
访问测试:
上面表示测试通过,日志中也有这条访问记录。