地址
- GitHub - apache/httpd: Mirror of Apache HTTP Server. Issues: http://issues.apache.org · GitHub
- GitHub - apache/apr: Mirror of Apache Portable Runtime · GitHub
- GitHub - apache/apr-util: Mirror of Apache Portable Runtime util · GitHub
安装必要软件
yum install -y wget
yum install -y tar
yum install -y make
# gcc 可缺省,已包含在下列软件中
yum install -y python2 autoconf libtool
yum install -y expat-devel
yum install -y pcre-devel
apr需要python、autoconf、libtool,否则将出现以下异常
异常输出
[root@anlois-8-8 apr-1.7.6]# ./buildconf
buildconf: checking installation...
buildconf: python not found.
You need python installed
to build APR from SVN.
buildconf: autoconf not found.
You need autoconf version 2.59 or newer installed
to build APR from SVN.
buildconf: libtool not found.
You need libtool version 1.4 or newer installed
to build APR from SVN.
[root@anlois-8-8 apr-1.7.6]#
apr-util需要expat-devel,否则将出现以下异常
异常输出
[root@anlois-8-8 apr-util-1.6.3]# make
make[1]: Entering directory '/root/apr-util-1.6.3'
......
xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory
#include <expat.h>
^~~~~~~~~
compilation terminated.
make[1]: *** [/root/apr-util-1.6.3/build/rules.mk:207: xml/apr_xml.lo] Error 1
make[1]: Leaving directory '/root/apr-util-1.6.3'
make: *** [/root/apr-util-1.6.3/build/rules.mk:119: all-recursive] Error 1
[root@anlois-8-8 apr-util-1.6.3]#
apr-util需要expat-devel,否则在 httpd 编译时,将出现以下异常
异常输出
[root@anlois-8-8 httpd-2.4.68]# make
Making all in srclib
make[1]: Entering directory '/root/httpd-2.4.68/srclib'
......
/usr/local/apr/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:48: htpasswd] Error 1
make[2]: Leaving directory '/root/httpd-2.4.68/support'
make[1]: *** [/root/httpd-2.4.68/build/rules.mk:75: all-recursive] Error 1
make[1]: Leaving directory '/root/httpd-2.4.68/support'
make: *** [/root/httpd-2.4.68/build/rules.mk:75: all-recursive] Error 1
[root@anlois-8-8 httpd-2.4.68]#
如果
apr-util安装完成后,可以看到下列内容,说明安装正确
异常输出
[root@anlois-8-8 apr-util-1.6.3]# ldd /usr/local/apr/lib/libaprutil-1.so | grep expat
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f5317e00000)
[root@anlois-8-8 apr-util-1.6.3]#
httpd需要pcre-devel,否则将出现以下异常
异常输出
[root@anlois-8-8 httpd-2.4.68]# ./configure
checking for chosen layout... Apache
......
checking for -pcre2-config... no
checking for -pcre-config... no
checking for pcre2-config... no
checking for pcre-config... no
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@anlois-8-8 httpd-2.4.68]#
下载
以版本号 httpd 2.4.68 为例
下载 apr
# 使用 GitHub 下载
wget --content-disposition https://github.com/apache/apr/archive/refs/tags/1.7.6.tar.gz
# 使用代理下载
wget --content-disposition https://gh-proxy.org/https://github.com/apache/apr/archive/refs/tags/1.7.6.tar.gz
# 使用 apache 归档仓库下载
wget --content-disposition https://archive.apache.org/dist/apr/apr-1.7.6.tar.gz
下载 apr-util
# 使用 GitHub 下载
wget --content-disposition https://github.com/apache/apr-util/archive/refs/tags/1.6.3.tar.gz
# 使用代理下载
wget --content-disposition https://gh-proxy.org/https://github.com/apache/apr-util/archive/refs/tags/1.6.3.tar.gz
# 使用 apache 归档仓库下载
wget --content-disposition https://archive.apache.org/dist/apr/apr-util-1.6.3.tar.gz
下载 httpd
# 使用 GitHub 下载
wget --content-disposition https://github.com/apache/httpd/archive/refs/tags/2.4.68.tar.gz
# 使用代理下载
wget --content-disposition https://gh-proxy.org/https://github.com/apache/httpd/archive/refs/tags/2.4.68.tar.gz
# 使用 apache 归档仓库下载
wget --content-disposition https://archive.apache.org/dist/httpd/httpd-2.4.68.tar.gz
编译
编译 apr
tar -zxvf apr-1.7.6.tar.gz
cd apr-1.7.6
./buildconf
./configure
make
make install
./buildconf 输出
[root@anlois-8-8 apr-1.7.6]# ./buildconf
buildconf: checking installation...
buildconf: python version 2.7.18 (ok)
buildconf: autoconf version 2.69 (ok)
buildconf: libtool version 2.4.6 (ok)
buildconf: copying libtool helper files using /usr/bin/libtoolize
buildconf: creating include/arch/unix/apr_private.h.in ...
buildconf: creating configure ...
buildconf: generating 'make' outputs ...
buildconf: rebuilding rpm spec file
[root@anlois-8-8 apr-1.7.6]#
./configure 输出
[root@anlois-8-8 apr-1.7.6]# ./configure
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
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.7.6
checking for chosen layout... apr
checking for gcc... gcc
checking whether the C compiler works... yes
......
configure: creating ./config.status
config.status: creating Makefile
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
[root@anlois-8-8 apr-1.7.6]#
make 输出
[root@anlois-8-8 apr-1.7.6]# make
make[1]: Entering directory '/root/apr-1.7.6'
/bin/sh /root/apr-1.7.6/libtool --silent --mode=compile --tag=CC gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I./include -I/root/apr-1.7.6/include/arch/unix -I./include/arch/unix -I/root/apr-1.7.6/include/arch/unix -I/root/apr-1.7.6/include -I/root/apr-1.7.6/include/private -I/root/apr-1.7.6/include/private -o encoding/apr_encode.lo -c encoding/apr_encode.c && touch encoding/apr_encode.lo
......
sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/apr/build-1,' -e 's,^\(top_build.*=\).*$,\1/usr/local/apr/build-1,' < build/apr_rules.mk > build/apr_rules.out
make[1]: Leaving directory '/root/apr-1.7.6'
[root@anlois-8-8 apr-1.7.6]#
make install 输出
[root@anlois-8-8 apr-1.7.6]# make install
make[1]: Entering directory '/root/apr-1.7.6'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/root/apr-1.7.6'
/root/apr-1.7.6/build/mkdir.sh /usr/local/apr/lib /usr/local/apr/bin /usr/local/apr/build-1 \
/usr/local/apr/lib/pkgconfig /usr/local/apr/include/apr-1
/usr/bin/install -c -m 644 /root/apr-1.7.6/include/apr.h /usr/local/apr/include/apr-1
for f in /root/apr-1.7.6/include/apr_*.h; do \
/usr/bin/install -c -m 644 ${f} /usr/local/apr/include/apr-1; \
done
/bin/sh /root/apr-1.7.6/libtool --mode=install /usr/bin/install -c -m 755 libapr-1.la /usr/local/apr/lib
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.so.0.7.6 /usr/local/apr/lib/libapr-1.so.0.7.6
libtool: install: (cd /usr/local/apr/lib && { ln -s -f libapr-1.so.0.7.6 libapr-1.so.0 || { rm -f libapr-1.so.0 && ln -s libapr-1.so.0.7.6 libapr-1.so.0; }; })
libtool: install: (cd /usr/local/apr/lib && { ln -s -f libapr-1.so.0.7.6 libapr-1.so || { rm -f libapr-1.so && ln -s libapr-1.so.0.7.6 libapr-1.so; }; })
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.lai /usr/local/apr/lib/libapr-1.la
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.a /usr/local/apr/lib/libapr-1.a
libtool: install: chmod 644 /usr/local/apr/lib/libapr-1.a
libtool: install: ranlib /usr/local/apr/lib/libapr-1.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/apr/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 apr.exp /usr/local/apr/lib/apr.exp
/usr/bin/install -c -m 644 apr.pc /usr/local/apr/lib/pkgconfig/apr-1.pc
for f in libtool shlibtool; do \
if test -f ${f}; then /usr/bin/install -c -m 755 ${f} /usr/local/apr/build-1; fi; \
done
/usr/bin/install -c -m 755 /root/apr-1.7.6/build/mkdir.sh /usr/local/apr/build-1
for f in make_exports.awk make_var_export.awk; do \
/usr/bin/install -c -m 644 /root/apr-1.7.6/build/${f} /usr/local/apr/build-1; \
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
[root@anlois-8-8 apr-1.7.6]#
编译 apr-util
tar -zxvf apr-util-1.6.3.tar.gz
cd apr-util-1.6.3
./buildconf --with-apr=../apr-1.7.6
./configure --with-apr=../apr-1.7.6 --with-expat=/usr
make
make install
ldd /usr/local/apr/lib/libaprutil-1.so | grep expat
echo '/usr/local/apr/lib' > /etc/ld.so.conf.d/apr.conf
ldconfig
./buildconf 输出
[root@anlois-8-8 apr-util-1.6.3]# ./buildconf --with-apr=../apr-1.7.6
Looking for apr source in /root/apr-1.7.6
Creating include/private/apu_config.h ...
Creating configure ...
Generating 'make' outputs ...
rebuilding rpm spec file
[root@anlois-8-8 apr-util-1.6.3]#
./configure 输出
[root@anlois-8-8 apr-util-1.6.3]# ./configure --with-apr=../apr-1.7.6 --with-expat=/usr
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
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.6.3
checking for chosen layout... apr-util
checking for gcc... gcc
checking whether the C compiler works... yes
......
configure: creating ./config.status
config.status: creating Makefile
config.status: creating export_vars.sh
config.status: creating build/pkg/pkginfo
config.status: creating apr-util.pc
config.status: creating apu-1-config
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
[root@anlois-8-8 apr-util-1.6.3]#
make 输出
[root@anlois-8-8 apr-util-1.6.3]# make
make[1]: Entering directory '/root/apr-util-1.6.3'
/bin/sh /root/apr-1.7.6/libtool --silent --mode=compile --tag=CC gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/apr-util-1.6.3/include -I/root/apr-util-1.6.3/include/private -I/root/apr-1.7.6/include -o buckets/apr_brigade.lo -c buckets/apr_brigade.c && touch buckets/apr_brigade.lo
......
gcc -E -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/apr-util-1.6.3/include -I/root/apr-util-1.6.3/include/private -I/root/apr-1.7.6/include export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> aprutil.exp
sed 's,^\(location=\).*$,\1installed,' < apu-1-config > apu-config.out
make[1]: Leaving directory '/root/apr-util-1.6.3'
[root@anlois-8-8 apr-util-1.6.3]#
make install 输出
[root@anlois-8-8 apr-util-1.6.3]# make install
make[1]: Entering directory '/root/apr-util-1.6.3'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/root/apr-util-1.6.3'
/root/apr-1.7.6/build/mkdir.sh /usr/local/apr/include/apr-1 /usr/local/apr/lib/pkgconfig \
/usr/local/apr/lib /usr/local/apr/bin
for f in /root/apr-util-1.6.3/include/*.h /root/apr-util-1.6.3/include/*.h; do \
/usr/bin/install -c -m 644 ${f} /usr/local/apr/include/apr-1; \
done
/usr/bin/install -c -m 644 apr-util.pc /usr/local/apr/lib/pkgconfig/apr-util-1.pc
list=''; for i in $list; do \
( cd $i ; make DESTDIR= install ); \
done
/bin/sh /root/apr-1.7.6/libtool --mode=install /usr/bin/install -c -m 755 libaprutil-1.la /usr/local/apr/lib
libtool: warning: relinking 'libaprutil-1.la'
libtool: install: (cd /root/apr-util-1.6.3; /bin/sh "/root/apr-1.7.6/libtool" --silent --tag CC --mode=relink gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/apr-util-1.6.3/include -I/root/apr-util-1.6.3/include/private -I/root/apr-1.7.6/include -version-info 6:3:6 -o libaprutil-1.la -rpath /usr/local/apr/lib buckets/apr_brigade.lo buckets/apr_buckets.lo buckets/apr_buckets_alloc.lo buckets/apr_buckets_eos.lo buckets/apr_buckets_file.lo buckets/apr_buckets_flush.lo buckets/apr_buckets_heap.lo buckets/apr_buckets_mmap.lo buckets/apr_buckets_pipe.lo buckets/apr_buckets_pool.lo buckets/apr_buckets_refcount.lo buckets/apr_buckets_simple.lo buckets/apr_buckets_socket.lo crypto/apr_crypto.lo crypto/apr_md4.lo crypto/apr_md5.lo crypto/apr_passwd.lo crypto/apr_sha1.lo crypto/apr_siphash.lo crypto/crypt_blowfish.lo crypto/getuuid.lo crypto/uuid.lo dbd/apr_dbd.lo dbm/apr_dbm.lo dbm/apr_dbm_sdbm.lo dbm/sdbm/sdbm.lo dbm/sdbm/sdbm_hash.lo dbm/sdbm/sdbm_lock.lo dbm/sdbm/sdbm_pair.lo encoding/apr_base64.lo hooks/apr_hooks.lo ldap/apr_ldap_stub.lo ldap/apr_ldap_url.lo memcache/apr_memcache.lo misc/apr_date.lo misc/apr_queue.lo misc/apr_reslist.lo misc/apr_rmm.lo misc/apr_thread_pool.lo misc/apu_dso.lo misc/apu_version.lo redis/apr_redis.lo strmatch/apr_strmatch.lo uri/apr_uri.lo xlate/xlate.lo xml/apr_xml.lo -lrt -lcrypt -lpthread -ldl -lcrypt /root/apr-1.7.6/libapr-1.la -lrt -lpthread -ldl )
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.so.0.6.3T /usr/local/apr/lib/libaprutil-1.so.0.6.3
libtool: install: (cd /usr/local/apr/lib && { ln -s -f libaprutil-1.so.0.6.3 libaprutil-1.so.0 || { rm -f libaprutil-1.so.0 && ln -s libaprutil-1.so.0.6.3 libaprutil-1.so.0; }; })
libtool: install: (cd /usr/local/apr/lib && { ln -s -f libaprutil-1.so.0.6.3 libaprutil-1.so || { rm -f libaprutil-1.so && ln -s libaprutil-1.so.0.6.3 libaprutil-1.so; }; })
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.lai /usr/local/apr/lib/libaprutil-1.la
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.a /usr/local/apr/lib/libaprutil-1.a
libtool: install: chmod 644 /usr/local/apr/lib/libaprutil-1.a
libtool: install: ranlib /usr/local/apr/lib/libaprutil-1.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/apr/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr/bin/apu-1-config
[root@anlois-8-8 apr-util-1.6.3]#
输出
[root@anlois-8-8 apr-util-1.6.3]# ldd /usr/local/apr/lib/libaprutil-1.so | grep expat
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f5317e00000)
[root@anlois-8-8 apr-util-1.6.3]#
输出
[root@anlois-8-8 apr-util-1.6.3]# echo '/usr/local/apr/lib' > /etc/ld.so.conf.d/apr.conf
[root@anlois-8-8 apr-util-1.6.3]# ldconfig
[root@anlois-8-8 apr-util-1.6.3]#
编译 httpd
tar -zxvf httpd-2.4.68.tar.gz
cd httpd-2.4.68
./buildconf --with-apr=/usr/local/apr/bin/apr-1-config
./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr
make
make install
./buildconf 输出
[root@anlois-8-8 httpd-2.4.68]# ./buildconf --with-apr=/usr/local/apr/bin/apr-1-config
testing apr-config executable: /usr/local/apr/bin/apr-1-config
using apr-config version 1.7.6
copying build files
cp: cannot stat '/usr/local/apr/build-1/apr_common.m4': No such file or directory
cp: cannot stat '/usr/local/apr/build-1/find_apr.m4': No such file or directory
cp: cannot stat '/usr/local/apr/build-1/find_apu.m4': No such file or directory
rebuilding include/ap_config_auto.h.in
rebuilding configure
rebuilding rpm spec file
fixing timestamps for ap_expr sources
[root@anlois-8-8 httpd-2.4.68]#
上面三行 cp 错误可以安全忽略,这些 m4 文件仅用于重新构建 apr 自身,不影响 httpd 编译。
./configure 输出
[root@anlois-8-8 httpd-2.4.68]# ./configure --with-apr=/usr/local/apr --with-apr-util=/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... yes
checking for gcc... gcc
checking whether the C compiler works... yes
......
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.68
Install prefix: /usr/local/apache2
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@anlois-8-8 httpd-2.4.68]#
make 输出
[root@anlois-8-8 httpd-2.4.68]# make
Making all in srclib
make[1]: Entering directory '/root/httpd-2.4.68/srclib'
make[1]: Leaving directory '/root/httpd-2.4.68/srclib'
Making all in os
make[1]: Entering directory '/root/httpd-2.4.68/os'
Making all in unix
make[2]: Entering directory '/root/httpd-2.4.68/os/unix'
make[3]: Entering directory '/root/httpd-2.4.68/os/unix'
/usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/root/httpd-2.4.68/os/unix -I/root/httpd-2.4.68/include -I/usr/local/apr/include/apr-1 -I/root/httpd-2.4.68/modules/aaa -I/root/httpd-2.4.68/modules/cache -I/root/httpd-2.4.68/modules/core -I/root/httpd-2.4.68/modules/database -I/root/httpd-2.4.68/modules/filters -I/root/httpd-2.4.68/modules/ldap -I/root/httpd-2.4.68/modules/loggers -I/root/httpd-2.4.68/modules/lua -I/root/httpd-2.4.68/modules/proxy -I/root/httpd-2.4.68/modules/http2 -I/root/httpd-2.4.68/modules/session -I/root/httpd-2.4.68/modules/ssl -I/root/httpd-2.4.68/modules/test -I/root/httpd-2.4.68/server -I/root/httpd-2.4.68/modules/md -I/root/httpd-2.4.68/modules/arch/unix -I/root/httpd-2.4.68/modules/dav/main -I/root/httpd-2.4.68/modules/generators -I/root/httpd-2.4.68/server -I/root/httpd-2.4.68/modules/mappers -prefer-non-pic -static -c unixd.c && touch unixd.lo
/usr/local/apr/build-1/libtool --silent --mode=link gcc -g -O2 -pthread -o libos.la -static unixd.lo
make[3]: Leaving directory '/root/httpd-2.4.68/os/unix'
make[2]: Leaving directory '/root/httpd-2.4.68/os/unix'
make[1]: Leaving directory '/root/httpd-2.4.68/os'
Making all in server
make[1]: Entering directory '/root/httpd-2.4.68/server'
Making all in mpm
make[2]: Entering directory '/root/httpd-2.4.68/server/mpm'
Making all in event
make[3]: Entering directory '/root/httpd-2.4.68/server/mpm/event'
make[4]: Entering directory '/root/httpd-2.4.68/server/mpm/event'
......
/usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/root/httpd-2.4.68/os/unix -I/root/httpd-2.4.68/include -I/usr/local/apr/include/apr-1 -I/root/httpd-2.4.68/modules/aaa -I/root/httpd-2.4.68/modules/cache -I/root/httpd-2.4.68/modules/core -I/root/httpd-2.4.68/modules/database -I/root/httpd-2.4.68/modules/filters -I/root/httpd-2.4.68/modules/ldap -I/root/httpd-2.4.68/modules/loggers -I/root/httpd-2.4.68/modules/lua -I/root/httpd-2.4.68/modules/proxy -I/root/httpd-2.4.68/modules/http2 -I/root/httpd-2.4.68/modules/session -I/root/httpd-2.4.68/modules/ssl -I/root/httpd-2.4.68/modules/test -I/root/httpd-2.4.68/server -I/root/httpd-2.4.68/modules/md -I/root/httpd-2.4.68/modules/arch/unix -I/root/httpd-2.4.68/modules/dav/main -I/root/httpd-2.4.68/modules/generators -I/root/httpd-2.4.68/server -I/root/httpd-2.4.68/modules/mappers -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo
/usr/local/apr/build-1/libtool --silent --mode=link gcc -g -O2 -pthread -o mod_rewrite.la -rpath /usr/local/apache2/modules -module -avoid-version mod_rewrite.lo
make[4]: Leaving directory '/root/httpd-2.4.68/modules/mappers'
make[3]: Leaving directory '/root/httpd-2.4.68/modules/mappers'
make[2]: Leaving directory '/root/httpd-2.4.68/modules'
make[2]: Entering directory '/root/httpd-2.4.68/support'
make[2]: Leaving directory '/root/httpd-2.4.68/support'
make[1]: Leaving directory '/root/httpd-2.4.68'
[root@anlois-8-8 httpd-2.4.68]#
make install 输出
[root@anlois-8-8 httpd-2.4.68]# make install
Making install in srclib
make[1]: Entering directory '/root/httpd-2.4.68/srclib'
make[2]: Entering directory '/root/httpd-2.4.68/srclib'
make[2]: Leaving directory '/root/httpd-2.4.68/srclib'
make[1]: Leaving directory '/root/httpd-2.4.68/srclib'
Making install in os
......
make[2]: Entering directory '/root/httpd-2.4.68/support'
make[2]: Leaving directory '/root/httpd-2.4.68/support'
Installing configuration files
mkdir /usr/local/apache2/conf
mkdir /usr/local/apache2/conf/extra
mkdir /usr/local/apache2/conf/original
mkdir /usr/local/apache2/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache2/htdocs
Installing error documents
mkdir /usr/local/apache2/error
Installing icons
mkdir /usr/local/apache2/icons
mkdir /usr/local/apache2/logs
Installing CGIs
mkdir /usr/local/apache2/cgi-bin
Installing header files
mkdir /usr/local/apache2/include
Installing build system files
mkdir /usr/local/apache2/build
Installing man pages and online manual
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make[1]: Leaving directory '/root/httpd-2.4.68'
[root@anlois-8-8 httpd-2.4.68]#
测试完成的二进制
find /usr/local/apache2/bin
/usr/local/apache2/bin/httpd -v
/usr/local/apache2/bin/httpd -V
/usr/local/apache2/bin/httpd -M
/usr/local/apache2/bin/httpd -l
/usr/local/apache2/bin/apachectl -v
/usr/local/apache2/bin/apachectl -V
/usr/local/apache2/bin/apachectl -M
/usr/local/apache2/bin/apachectl -l
find /usr/local/apache2/bin 输出
[root@anlois-8-8 httpd-2.4.68]# find /usr/local/apache2/bin
/usr/local/apache2/bin
/usr/local/apache2/bin/htpasswd
/usr/local/apache2/bin/htdigest
/usr/local/apache2/bin/htdbm
/usr/local/apache2/bin/ab
/usr/local/apache2/bin/logresolve
/usr/local/apache2/bin/httxt2dbm
/usr/local/apache2/bin/htcacheclean
/usr/local/apache2/bin/rotatelogs
/usr/local/apache2/bin/checkgid
/usr/local/apache2/bin/fcgistarter
/usr/local/apache2/bin/apxs
/usr/local/apache2/bin/dbmmanage
/usr/local/apache2/bin/apachectl
/usr/local/apache2/bin/envvars-std
/usr/local/apache2/bin/envvars
/usr/local/apache2/bin/httpd
[root@anlois-8-8 httpd-2.4.68]#
httpd -v 输出
[root@anlois-8-8 httpd-2.4.68]# /usr/local/apache2/bin/httpd -v
Server version: Apache/2.4.68 (Unix)
Server built: Jun 11 2026 23:01:32
[root@anlois-8-8 httpd-2.4.68]#
httpd -V 输出
[root@anlois-8-8 httpd-2.4.68]# /usr/local/apache2/bin/httpd -V
Server version: Apache/2.4.68 (Unix)
Server built: Jun 11 2026 23:01:32
Server's Module Magic Number: 20120211:142
Server loaded: APR 1.7.6, APR-UTIL 1.6.3, PCRE 10.32 2018-09-10
Compiled using: APR 1.7.6, APR-UTIL 1.6.3, PCRE 10.32 2018-09-10
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_PROC_PTHREAD_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr/local/apache2"
-D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@anlois-8-8 httpd-2.4.68]#
httpd -M 输出
[root@anlois-8-8 httpd-2.4.68]# /usr/local/apache2/bin/httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::be24:11ff:fe06:5a8f%ens18. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_event_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
auth_basic_module (shared)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)
[root@anlois-8-8 httpd-2.4.68]#
httpd -l 输出
[root@anlois-8-8 httpd-2.4.68]# /usr/local/apache2/bin/httpd -l
Compiled in modules:
core.c
mod_so.c
http_core.c
event.c
[root@anlois-8-8 httpd-2.4.68]#
添加环境变量
echo 'PATH=/usr/local/apache2/bin:$PATH' >> /etc/profile
echo 'export PATH' >> /etc/profile
source /etc/profile
httpd -v
httpd -V
httpd -M
httpd -l
apachectl -v
apachectl -V
apachectl -M
apachectl -l
输出
[root@anlois-8-8 httpd-2.4.68]# echo 'PATH=/usr/local/apache2/bin:$PATH' >> /etc/profile
[root@anlois-8-8 httpd-2.4.68]# source /etc/profile
Linux Service
源码编译安装不会自动创建 systemd service 文件,需要手动添加。
可以基于 httpd 启动,也可以基于 apachectl 启动,以下方式二选一
apache2.service
cat > /usr/lib/systemd/system/apache2.service << 'EOF'
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/apache2/logs/httpd.pid
Environment=LANG=C
EnvironmentFile=/usr/local/apache2/bin/envvars
ExecStart=/usr/local/apache2/bin/apachectl -k start
ExecStop=/usr/local/apache2/bin/apachectl -k stop
ExecReload=/usr/local/apache2/bin/apachectl -k graceful
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start apache2
systemctl enable apache2
systemctl status apache2
httpd.service
cat > /usr/lib/systemd/system/httpd.service << 'EOF'
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/apache2/logs/httpd.pid
Environment=LANG=C
EnvironmentFile=/usr/local/apache2/bin/envvars
ExecStart=/usr/local/apache2/bin/httpd -k start
ExecStop=/usr/local/apache2/bin/httpd -k stop
ExecReload=/usr/local/apache2/bin/httpd -k graceful
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start httpd
systemctl enable httpd
systemctl status httpd