编译httpd细节详解

本文目录
1.1 下载和解决依赖关系
1.2 httpd编译选项
1.3 模块动静态编译
1.4 动静态编译的优先级规则
1.5 MPM的安装
1.6 关于"--enable-so"
1.7 开始编译httpd
1.8 编译后的规范操作

1.1 下载和解决依赖

以httpd 2.4.27为例。

资源下载:

apache自己的站点提供了基金会下所有的(包括所有版本)资源,包括httpd。

地址:
httpd下载地址:

清华大学有一个httpd归档的镜像站点,里面提供最新测试版和最新稳定版的下载,还提供一些依赖包或模块的下载。

地址:
apache基金会下所有资源地址:

httpd同样使用"./configure"、"make && make install"的编译流程编译。但是它有一些依赖包需要提前装好。官方上指定的依赖环境有:apr、apr-util、pcre、pcre-devle,此外还需要expat-devel包。其中pcre、pcre-devel和expat.devel可以直接使用yum安装,apr和apr-util需要编译安装。下载地址可以从站点 找到。

yum -y install pcre pcre-devel expat-devel

以下是编译apr和apr-util的过程。

tar xf apr-1.6.2.tar.gz tar xf arp-1.6.0.tar.gz cd apr-1.6.0 ./configure --prefix=/usr/local/apr make make install cd ../apr-util-1.6.2 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make make install

然后是编译httpd,httpd编译对刚接触的人来说可能有些麻烦,因为编译选项太多,其中的一些"潜规则"也不太熟悉。所以下面详细地说明说明。

1.2 httpd编译选项

httpd的编译选项非常多。以下是截取./configure -h中的一部分,使用"......"表示省略了一堆信息。

Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print `checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local/apache2] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, `make install' will install all the files in `/usr/local/apache2/bin', `/usr/local/apache2/lib' etc. You can specify an installation prefix other than `/usr/local/apache2' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] ........................................ System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-layout=LAYOUT --enable-dtrace Enable DTrace probes --enable-hook-probes Enable APR hook probes --enable-exception-hook Enable fatal exception hook --enable-load-all-modules Load all modules --enable-maintainer-mode Turn on debugging and compile time warnings and load all compiled modules --enable-debugger-mode Turn on debugging and compile time warnings and turn off optimization --enable-pie Build httpd as a Position Independent Executable --enable-modules=MODULE-LIST Space-separated list of modules to enable | "all" | "most" | "few" | "none" | "reallyall" --enable-mods-shared=MODULE-LIST Space-separated list of shared modules to enable | "all" | "most" | "few" | "reallyall" --enable-mods-static=MODULE-LIST Space-separated list of static modules to enable | "all" | "most" | "few" | "reallyall" ......................................... Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-included-apr Use bundled copies of APR/APR-Util --with-apr=PATH prefix for installed APR or the full path to apr-config --with-apr-util=PATH prefix for installed APU or the full path to apu-config --with-pcre=PATH Use external PCRE library ....................

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/22ea27474e2f8d5656f62d0f67e569bd.html