httpd编译安装
基础环境准备
[root@liuquanyu ~]# dnf -y install gcc gcc-c++ make wget
Last metadata expiration check: 2:28:48 ago on Tue 13 Dec 2022 06:32:26 PM CST.
Package gcc-8.5.0-4.el8_5.x86_64 is already installed.
Package gcc-c++-8.5.0-4.el8_5.x86_64 is already installed.
Package make-1:4.2.1-10.el8.x86_64 is already installed.
Package wget-1.19.5-10.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
下载源码安装包
在usr/src目录下使用wget命令下载三个源码安装包
[root@liuquanyu ~]# cd /usr/src/
[root@liuquanyu src]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
...
Downloaded: 3 files, 11M in 6m 18s (29.5 KB/s
[root@liuquanyu src]# ls
apr-1.7.0.tar.gz debug kernels
apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
apr编译安装
解压源码包,并进入该目录
[root@liuquanyu src]# tar xf apr-1.7.0.tar.gz
[root@liuquanyu src]# cd apr-1.7.0
[root@liuquanyu apr-1.7.0]# ls
apr-config.in build.conf dso libapr.rc NOTICE support
apr.dep buildconf emacs-mode LICENSE NWGNUmakefile tables
apr.dsp build-outputs.mk encoding locks passwd test
apr.dsw CHANGES file_io Makefile.in poll threadproc
apr.mak CMakeLists.txt helpers Makefile.win random time
apr.pc.in config.layout include memory README tools
apr.spec configure libapr.dep misc README.cmake user
atomic configure.in libapr.dsp mmap shmem
build docs libapr.mak network_io strings
指定要安装的路径
[root@liuquanyu apr-1.7.0]# ./configure --prefix=/usr/local/apr
...
config.status: include/arch/unix/apr_private.h is unchanged
检测通过后生产Makefile文件
[root@liuquanyu apr-1.7.0]# ls
apr-1-config build configure libapr.dsp misc shmem
apr-config.in build.conf configure.in libapr.mak mmap strings
apr.dep buildconf docs libapr.rc network_io support
apr.dsp build-outputs.mk dso libtool NOTICE tables
apr.dsw CHANGES emacs-mode LICENSE NWGNUmakefile test
apr.mak CMakeLists.txt encoding locks passwd threadproc
apr.pc config.layout file_io Makefile poll time
apr.pc.in config.log helpers Makefile.in random tools
apr.spec config.nice include Makefile.win README user
atomic config.status libapr.dep memory README.cmake
执行make -j命令进行编译
[root@liuquanyu apr-1.7.0]# make -j 4
make[1]: Entering directory '/usr/src/apr-1.7.0'
...
make[1]: Leaving directory '/usr/src/apr-1.7.0'
按Makefile定义好的路径拷贝至安装目录中
[root@liuquanyu apr-1.7.0]# make install
...
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
apr-util编译安装
解压源码包
[root@liuquanyu src]# tar xf apr-util-1.6.1.tar.gz
[root@liuquanyu src]# cd apr-util-1.6.1
[root@liuquanyu apr-util-1.6.1]#
指定安装路径
#还要with关联apr
[root@liuquanyu apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
...
config.status: creating include/private/apu_config.h
config.status: executing default commands
检测通过后生产Makefile文件
[root@liuquanyu apr-util-1.6.1]# ls
aprutil.dep buckets config.nice export_vars.sh LICENSE README.cmake
aprutil.dsp build config.status export_vars.sh.in Makefile README.FREETDS
aprutil.dsw build.conf configure hooks Makefile.in redis
aprutil.mak buildconf configure.in include Makefile.win renames_pending
apr-util.pc build-outputs.mk crypto ldap memcache strmatch
apr-util.pc.in CHANGES dbd libaprutil.dep misc test
apr-util.spec CMakeLists.txt dbm libaprutil.dsp NOTICE uri
apu-1-config config.layout docs libaprutil.mak NWGNUmakefile xlate
apu-config.in config.log encoding libaprutil.rc README xml
执行make -j命令进行编译
[root@liuquanyu apr-util-1.6.1]# make -j 4
...
make[1]: Leaving directory '/usr/src/apr-util-1.6.1'
按Makefile定义好的路径拷贝至安装目录中
[root@liuquanyu httpd-2.4.54]# make install
...
mkdir /usr/local/apache/manual
make[1]: Leaving directory '/usr/src/httpd-2.4.54'
设置环境变量
[root@liuquanyu local]# ls
apache apr apr-util bin etc games include lib lib64 libexec nginx sbin share src
[root@liuquanyu local]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@liuquanyu local]# source /etc/profile.d/apache.sh
[root@liuquanyu local]# which httpd
/usr/local/apache/bin/httpd
[root@liuquanyu local]#
设置映射关系
[root@liuquanyu local]# ls /usr/local/apache/
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@liuquanyu local]#
[root@liuquanyu local]# ln -s /usr/local/apache/include/ /usr/include/apache
设置man文档
[root@liuquanyu ~]# vi /etc/man_db.conf
...
#MANDATORY_MANPATH /usr/src/pvm3/man
#
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/apache/man
总结配置中的报错
rm: cannot remove 'libtoolT': No such file or directory
//解决办法
将configure文件中的$RM "$cfgfile"这行代码注释掉就可以了
xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory
#include <expat.h>
^~~~~~~~~
compilation terminated.
make[1]: *** [/usr/src/apr-util-1.6.1/build/rules.mk:206: xml/apr_xml.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/usr/src/apr-util-1.6.1'
make: *** [/usr/src/apr-util-1.6.1/build/rules.mk:118: all-recursive] Error 1
//解决办法
[root@node-2 apr-util-1.6.1]# yum install -y expat-devel
configure: error: APR-util not found. Please read the documentation.
//解决办法
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:48: htpasswd] Error 1
make[2]: Leaving directory '/usr/src/httpd-2.4.54/support'
make[1]: *** [/usr/src/httpd-2.4.54/build/rules.mk:75: all-recursive] Error 1
make[1]: Leaving directory '/usr/src/httpd-2.4.54/support'
make: *** [/usr/src/httpd-2.4.54/build/rules.mk:75: all-recursive] Error 1
//解决办法
yum install -y libxml2-devel //安装libxml2-devel
rm -rf /usr/local/apr-util //删除apr-util目录并且重新编译安装
cd /usr/local/src/apr-util-1.6.1/
make clean
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install 重新编译安装httpd,成功解决
标签:httpd,liuquanyu,apr,root,local,util,编译,usr,安装
From: https://www.cnblogs.com/lqy0917/p/17004503.html