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

在Amazon Linux 2编译Nginx时--with-ld-opt参数报错,求正确取值

问题解决:Nginx编译时--with-ld-opt="-Wl,-E"参数报错

原因分析

从失败日志可见,你是在aarch64(ARM64)架构的Amazon Linux 2环境下编译Nginx 1.22.0,-Wl,-E这个链接器选项在该架构的编译器环境中不被支持,Nginx的configure脚本检测不到该选项的有效性,因此抛出报错。

解决方案

直接移除--with-ld-opt='-Wl,-E'参数即可完成编译,若后续遇到动态链接相关问题,可替换为适配ARM64架构的链接选项。

修改后的configure命令片段

将原命令中的--with-ld-opt='-Wl,-E'部分删除:

./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --add-dynamic-module=/opt/nginx_cookie_flag_module/

若后续编译出现动态链接问题,可尝试替换为ARM64适配的选项:

--with-ld-opt='-Wl,--enable-new-dtags'

额外说明

-Wl,-E的作用是让链接器导出所有符号,多用于x86_64架构下支持动态模块加载,但在ARM64架构的Amazon Linux 2环境中,Nginx编译默认已处理动态模块的链接需求,无需额外指定该选项。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 17:55:19