无法加载 /etc/httpd/modules/mod_auth_basic.so

Ric*_*ckD 2 apache-2.2

在尝试通过从头编译 2.4.7 将 apache 2.2.3 升级到 2.4.7 之后。我收到以下错误,

[root@test httpd-2.4.7]# /etc/init.d/httpd start
Starting httpd: httpd: Syntax error on line 149 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/mod_auth_basic.so into server: /etc/httpd/modules/mod_auth_basic.so: undefined symbol: ap_expr_str_exec
                                                           [FAILED]
Run Code Online (Sandbox Code Playgroud)

但是文件在那里,

/etc/httpd/modules/mod_auth_basic.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
Run Code Online (Sandbox Code Playgroud)

我 2.2.3 的原始 conf 在 /etc/httpd 中,我运行编译的命令是,

cd apr-1.5.0/
./configure --prefix=/usr/local/apr-httpd/
make
make install

cd ../apr-util-1.5.3/
./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/
make
make install

cd ../pcre-8.32/
./configure --prefix=/usr/local/pcre-8.32
make
make install


cd ../httpd-2.4.7/
./configure --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/ --with-pcre=/usr/local/pcre-8.32/ --prefix=/etc/httpd
make 
make install
Run Code Online (Sandbox Code Playgroud)

有任何想法吗 ?

voe*_*eba 5

ap_expr_str_exec是Apache httpd 2.4 核心中新引入的 API 函数。错误是您的运行时链接器抱怨 mod_auth_basic.so 模块需要解析ap_expr_str_exec符号,但没有找到它。

您可以使用 readelf 命令的输出来验证这一点:

$ readelf -s modules/mod_auth_basic.so
   Num:    Value          Size Type    Bind   Vis      Ndx Name
   ...
     3: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND ap_expr_str_exec
   ...
Run Code Online (Sandbox Code Playgroud)

符号索引的 UND 值意味着它是未定义的,因此必须在运行时解析。

因此,由于您的模块引用了 2.4 符号但您正在运行的可执行文件没有它,因此看起来像是尝试将 httpd 2.4 模块加载到 httpd 2.2 实例中。确保您运行的是正确的 httpd 二进制文件。

  • 仅供参考,调试此类符号错误的另一个有用工具是“LD_DEBUG”环境变量。尝试运行下面的命令,运行时链接器将转储大量关于它正在加载的库以及它在哪里获取(或未获取)符号的调试信息:`$ LD_DEBUG=all ./bin/httpd-2.4.7 - f conf/modauthbasic.conf 2>&1 | 少` (2认同)