apr 是 apache httpd 2.4+ 编译的必需依赖,不可省略;开发/测试推荐内置 apr(放入 srclib 并用 --with-included-apr),生产环境推荐复用已安装 apr(指定 --with-apr 和 --with-apr-util);需注意版本兼容与 expat/libtool 等依赖,最后通过 httpd -v 和 error_log 验证生效。

Apache 源码编译时,APR(Apache Portable Runtime)不是“可选配”,而是必须满足的底层依赖。HTTPD 2.4+ 版本不再自带 APR,必须显式提供——配错或缺失会导致 configure 失败,常见报错如 configure: error: APR not found 或 APR-util not found。
Apache Superset 是一个广泛采用的开源 BI 平台,用于 SQL 探索、图表构建和仪表板交付。当代理需要查询仓库数据、组装仪表板或使用成熟的分析界面解释指标而不是临时笔记本代码时,此技能非常有用。
APR 配置方式有两种,按场景选一种
推荐开发/测试环境:内置 APR(最省事、版本可控)
把 APR 和 APR-util 源码直接放进 httpd 源码树的 srclib/ 目录:
- 解压
apr-1.7.x到httpd-2.4.x/srclib/apr - 解压
apr-util-1.6.x到httpd-2.4.x/srclib/apr-util - 运行
./configure --with-included-apr ...(无需指定路径) - 优点:避免系统 APR 版本冲突,调试方便,适合单机部署
推荐生产环境:复用已安装的 APR(更稳定、易维护)
先独立编译安装 APR 和 APR-util 到自定义路径(如 /usr/local/apr),再在 httpd configure 中指定:
--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util- 确保
/usr/local/apr/bin/apr-1-config可执行,且头文件、库路径正确 - 注意:APR 和 APR-util 版本需兼容(例如 apr-1.7.x + apr-util-1.6.x)
常见报错与对应处理
“expat.h: No such file or directory”
apr-util 编译时报此错,说明缺少 XML 解析支持:
- CentOS/RHEL:运行
yum install -y expat-devel - Ubuntu/Debian:运行
apt install -y libexpat1-dev
“libtoolT: No such file or directory”
老版本 apr configure 脚本 bug,临时修复方法:
- 编辑
configure文件,搜索RM='$RM',改为RM='$RM -f' - 或直接装系统 libtool:
yum install -y libtool
验证 APR 是否生效
编译成功后,启动 Apache,执行:
-
httpd -V | grep -i apr→ 应显示 APR 和 APR-util 的路径与版本 -
httpd -M | grep mpm→ MPM 模块加载正常,说明 APR 线程/进程模型已就绪 - 查看
error_log,无apr_pollset_create或apr_thread_*类错误










