You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Fedora Server 37/38编译mod_jk 1.2.x失败求助

编译mod_jk时ld选项错误的解决方法(Fedora Server 37/38)

问题场景

在全新安装的Fedora Server 37/38系统中,按以下步骤尝试编译安装mod_jk:

  1. 安装依赖:dnf install httpd mod_ssl httpd-devel redhat-rpm-config
  2. 下载tomcat-connectors-1.2.48-src.tar.gz(及1.2.37版本)至/home/tmp,执行解压命令:tar -xvf tomcat-connectors-1.2.48-src.tar.gz
  3. 进入解压后的源码目录,执行配置命令:./configure -with-apxs=/usr/bin/apxs(注:正确参数应为--with-apxs,单连字符会导致配置错误,需修正)
  4. 执行make后触发链接错误:
    /usr/bin/ld: unrecognized option 'specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
    error: ld returned 1 exit status
    

问题原因

错误源于redhat-rpm-config包引入了RPM编译专属的硬化链接参数,mod_jk的configure脚本错误地将这些参数传递给了系统ld链接器。Fedora的ld并不支持该RPM专属选项,因此触发链接失败。

解决方法

方法1:临时清除RPM编译环境变量(快速解决)

在执行configure和make前,清除导致冲突的环境变量:

unset RPM_OPT_FLAGS
unset LDFLAGS

随后重新执行正确的配置和编译命令:

./configure --with-apxs=/usr/bin/apxs
make

编译完成后,可在native/apache-2.0目录下找到生成的mod_jk.so文件。

方法2:修改configure脚本(永久适配)

若需长期编译该版本的mod_jk,可修改源码目录下的configure脚本,移除RPM相关参数:

  1. 打开源码根目录的configure文件
  2. 搜索包含RPM_OPT_FLAGS的行(通常是将该变量追加到LDFLAGS的语句)
  3. 将该行注释或删除,保存后重新执行./configure --with-apxs=/usr/bin/apxs和make。

方法3:安装官方预编译包(推荐)

Fedora官方仓库已提供预编译的mod_jk包,无需手动编译,直接安装即可:

dnf install mod_jk

安装完成后,配置文件默认位于/etc/httpd/conf.d/mod_jk.conf,修改配置后重启httpd服务生效:

systemctl restart httpd

内容的提问来源于stack exchange,提问作者RickF

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 00:12:49