编译环境:
操作系统:CentOS7
httpd版本:2.4.58
制作工具:rpmbuild(这个之前的文章有介绍,看这里)
下载httpd源码:
官网目前的最新版本是2.4.58,下载备用,并放入准备好的编译机器上。
制作RPM包
找到安装包的位置,然后使用如下命令,即可开始制作RPM包:
bash
rpmbuild -tb httpd-2.4.58.tar.bz2
可能会报如下错误:
bash
error: Failed build dependencies:
autoconf is needed by httpd-2.4.58-1.x86_64
libuuid-devel is needed by httpd-2.4.58-1.x86_64
apr-devel >= 1.4.0 is needed by httpd-2.4.58-1.x86_64
apr-util-devel >= 1.4.0 is needed by httpd-2.4.58-1.x86_64
openldap-devel is needed by httpd-2.4.58-1.x86_64
lua-devel is needed by httpd-2.4.58-1.x86_64
libxml2-devel is needed by httpd-2.4.58-1.x86_64
openssl-devel is needed by httpd-2.4.58-1.x86_64
错误信息提示需要安装如上几个devel包,那就先安装:
bash
yum install -y autoconf libuuid-devel apr-devel apr-util-devel openldap-devel lua-devel libxml2-devel openssl-devel
安装成功之后,重新执行打包命令:
bash
rpmbuild -tb httpd-2.4.58.tar.bz2
可能会报如下错误:
bash
RPM build errors:
File not found: /root/rpmbuild/BUILDROOT/httpd-2.4.58-1.x86_64/usr/lib64/httpd/modules/mod_mpm_event.so
出现这个错误,是由于系统中的APR版本较低,查看APR版本,显示如下:
bash
[root@~ rpmbuild]# rpm -qa|grep apr
apr-util-1.5.2-6.el7.x86_64
apr-devel-1.4.8-7.el7.x86_64
apr-util-devel-1.5.2-6.el7.x86_64
apr-1.4.8-7.el7.x86_64
因此,我们需要升级APR。由于没有现成的APR高版本,所以,需要先制作APR的安装包,制作方法是一样的,先下载APR和APR-util的源码包,然后执行打包命令:
bash
rpmbuild -tb apr-1.7.4.tar.bz2
可能出现如下错误:
bash
error: Failed build dependencies:
libtool is needed by apr-1.7.4-1.x86_64
doxygen is needed by apr-1.7.4-1.x86_64
同前面一样,缺少依赖包,安装libtool和doxygen:
bash
[root@~ rpmbuild]# yum install -y libtool doxygen
重新执行APR的打包命令:
bash
rpmbuild -tb apr-1.7.4.tar.bz2
之后,执行APR-util的打包命令:
bash
rpmbuild -tb apr-util-1.6.3.tar.bz2
可能出现如下错误:
bash
error: Failed build dependencies:
db4-devel is needed by apr-util-1.6.3-1.x86_64
postgresql-devel is needed by apr-util-1.6.3-1.x86_64
mysql-devel is needed by apr-util-1.6.3-1.x86_64
sqlite-devel >= 3.0.0 is needed by apr-util-1.6.3-1.x86_64
unixODBC-devel is needed by apr-util-1.6.3-1.x86_64
nss-devel is needed by apr-util-1.6.3-1.x86_64
同前面一样,缺少依赖包,执行以下命令,安装依赖包:
bash
yum install -y db4-devel postgresql-devel mysql-devel sqlite-devel unixODBC-devel nss-devel
接着,重新执行APR-util的打包命令:
bash
rpmbuild -tb apr-util-1.6.3.tar.bz2
至此,APR和APR-util的rpm包制作好了,以下命令是进行升级操作:
bash
rpm -U /root/rpmbuild/RPMS/x86_64/apr-1.7.4-1.x86_64.rpm /root/rpmbuild/RPMS/x86_64/apr-devel-1.7.4-1.x86_64.rpm
rpm -U /root/rpmbuild/RPMS/x86_64/apr-util-1.6.3-1.x86_64.rpm /root/rpmbuild/RPMS/x86_64/apr-util-devel-1.6.3-1.x86_64.rpm
升级成功之后,重新执行打包HTTPD的命令:
bash
rpmbuild -tb httpd-2.4.58.tar.bz2
不出意外的话,httpd及其相关的rpm都将打包成功。默认情况下,安装包在/root/rpmbuild/RPMS/x86_64目录下。