目录
一、下载源码
二、编译&排错
2.1、第一次编译,解决依赖包问题。
2.2、第二次编译,解决anaconda导致的环境变量问题
2.3、第三次编译,解决apr版本过低问题
提供 apr-1.7.0、httpd-2.4.46 的RPM包下载。
apr-1.7.0-bundle.zip
httpd-2.4.46 -bundle.zip
一、下载源码
[root@lingmk ~]# cd rpmbuild/SOURCES/
[root@lingmk SOURCES]#
[root@lingmk SOURCES]# wget https://mirror.bit.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
…………[root@lingmk SOURCES]# sha256sum httpd-2.4.46.tar.bz2
740eddf6e1c641992b22359cabc66e6325868c3c5e2e3f98faf349b61ecf41ea httpd-2.4.46.tar.bz2
[root@lingmk SOURCES]#
[root@lingmk SOURCES]# tar xvjf httpd-2.4.46.tar.bz2
…………
[root@lingmk SOURCES]# cd httpd-2.4.46/
[root@lingmk httpd-2.4.46]# ll | grep spec
-rw-r--r-- 1 root 40 17313 Aug 1 22:11 httpd.spec
[root@lingmk httpd-2.4.46]# cp httpd.spec ../../SPECS/
[root@lingmk httpd-2.4.46]# cd ../../SPECS/
二、编译&排错
2.1、第一次编译,解决依赖包问题。
报错需要lua-devel,安装之。
[root@lingmk SPECS]# rpmbuild -ba httpd.spec
error: Failed build dependencies:lua-devel is needed by httpd-2.4.46-1.x86_64
[root@lingmk SPECS]#
[root@lingmk SPECS]# yum install lua-devel -y
2.2、第二次编译,解决anaconda导致的环境变量问题
报错 /usr/lib64/libapr-1.so: undefined reference to `uuid_generate@UUID_1.0'。
- 使用/usr/lib64/libapr-1.so时遇到一个未定义的uuid……。
- 我们用ldd命令看看/usr/lib64/libapr-1.so的库依赖,包含uuid的是libuuid.so.1。
- 我们再locate命令看看哪里有libuuid.so.1,发现在anaconda里面也有libuuid.so.1。
原因就是这个冲突导致的。我们可以查看PATH环境变量,果然anaconda排在前面。我们使用conda deactivate取消anaconda的环境变量。再次编译。
[root@lingmk SPECS]# rpmbuild -ba httpd.spec
…………
/usr/lib64/libapr-1.so: undefined reference to `uuid_generate@UUID_1.0'
collect2: error: ld returned 1 exit status
make[1]: *** [httpd] Error 1
make[1]: Leaving directory `/root/rpmbuild/BUILD/httpd-2.4.46'
make: *** [all-recursive] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.7JVKVB (%build)RPM build errors:Bad exit status from /var/tmp/rpm-tmp.7JVKVB (%build)
[root@lingmk SPECS]#
[root@lingmk SPECS]# ldd /usr/lib64/libapr-1.so | grep uuidlibuuid.so.1 => /lib64/libuuid.so.1 (0x00007fa4f959d000)
[root@lingmk SPECS]#
[root@lingmk SPECS]# locate libuuid.so.1
/data/anaconda3/lib/libuuid.so.1
/data/anaconda3/lib/libuuid.so.1.0.0
/data/anaconda3/pkgs/libuuid-1.0.3-h1bed415_2/lib/libuuid.so.1
/data/anaconda3/pkgs/libuuid-1.0.3-h1bed415_2/lib/libuuid.so.1.0.0
/usr/lib64/libuuid.so.1
/usr/lib64/libuuid.so.1.3.0
[root@lingmk SPECS]#
[root@lingmk SPECS]# echo $PATH
/data/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@lingmk SPECS]#
[root@lingmk SPECS]# conda deactivate
[root@lingmk SPECS]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@lingmk SPECS]#
2.3、第三次编译,解决apr版本过低问题
报错找不到文件/root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/lib64/httpd/modules/mod_mpm_event.so。
据说是由于apr(Apache Portable Runtime)的版本太低,CentOS7自带的是1.4.x版本的,需要将升级apr升级到1.5.x以上才行,目前最新的是1.7.0版本。我们先完成支线任务编译apr,再继续编译apache。编译成功。
[root@lingmk SPECS]# rpmbuild -ba httpd.spec
…………
+ grep TEXTREL
+ exit 0
Processing files: httpd-2.4.46-1.x86_64
error: File not found: /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/lib64/httpd/modules/mod_mpm_event.so
Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.fP4iVM
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd httpd-2.4.46
+ DOCDIR=/root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/share/doc/httpd-2.4.46
+ export DOCDIR
+ /usr/bin/mkdir -p /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/share/doc/httpd-2.4.46
+ cp -pr ABOUT_APACHE /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/share/doc/httpd-2.4.46
+ cp -pr README /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/share/doc/httpd-2.4.46
+ cp -pr CHANGES /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/share/doc/httpd-2.4.46
+ cp -pr LICENSE /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/share/doc/httpd-2.4.46
+ cp -pr NOTICE /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/share/doc/httpd-2.4.46
+ exit 0RPM build errors:File not found: /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64/usr/lib64/httpd/modules/mod_mpm_event.so
[root@lingmk SPECS]#
[root@lingmk SPECS]# cd ../SOURCES/
[root@lingmk SOURCES]# wget https://mirrors.bfsu.edu.cn/apache//apr/apr-1.7.0.tar.bz2
[root@lingmk SOURCES]# sha256sum apr-1.7.0.tar.bz2
e2e148f0b2e99b8e5c6caa09f6d4fb4dd3e83f744aa72a952f94f5a14436f7ea apr-1.7.0.tar.bz2
[root@lingmk SOURCES]#
[root@lingmk SOURCES]# tar xvjf apr-1.7.0.tar.bz2
[root@lingmk SOURCES]# cp apr-1.7.0/apr.spec ../SPECS/
[root@lingmk SOURCES]# cd ../SPECS/
[root@lingmk SPECS]#
[root@lingmk SPECS]# rpmbuild -ba apr.spec
…………
Wrote: /root/rpmbuild/SRPMS/apr-1.7.0-1.src.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/apr-1.7.0-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/apr-devel-1.7.0-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/apr-debuginfo-1.7.0-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.FxdyDh
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd apr-1.7.0
+ rm -rf /root/rpmbuild/BUILDROOT/apr-1.7.0-1.x86_64
+ exit 0
[root@lingmk SPECS]# cd ../RPMS/x86_64/
[root@lingmk x86_64]# yum localinstall apr-1.7.0-1.x86_64.rpm apr-devel-1.7.0-1.x86_64.rpm
[root@lingmk x86_64]# cd ../../SPECS/
[root@lingmk SPECS]# rpmbuild -ba httpd.spec
…………
Wrote: /root/rpmbuild/SRPMS/httpd-2.4.46-1.src.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/httpd-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/httpd-devel-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/httpd-manual-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/httpd-tools-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/mod_authnz_ldap-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/mod_lua-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/mod_proxy_html-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/mod_ssl-2.4.46-1.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/httpd-debuginfo-2.4.46-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.nL1uTo
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd httpd-2.4.46
+ rm -rf /root/rpmbuild/BUILDROOT/httpd-2.4.46-1.x86_64
+ exit 0
[root@lingmk SPECS]#