
通过宝塔面板安装和启动报错，通过AI解决了
1、安装报错日志：
objs/Makefile:3779: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_worker.o'
objs/Makefile:2820: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_worker.o'
objs/Makefile:3786: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_ssl_certby.o'
objs/Makefile:2834: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_ssl_certby.o'
objs/Makefile:3793: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_ssl_ocsp.o'
objs/Makefile:2841: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_ssl_ocsp.o'
objs/Makefile:3800: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_lex.o'
objs/Makefile:2848: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_lex.o'
objs/Makefile:3807: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_balancer.o'
objs/Makefile:2855: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_balancer.o'
objs/Makefile:3814: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_ssl_session_storeby.o'
objs/Makefile:2862: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_ssl_session_storeby.o'
objs/Makefile:3821: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_ssl_session_fetchby.o'
objs/Makefile:2869: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_ssl_session_fetchby.o'
objs/Makefile:3828: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_ssl.o'
objs/Makefile:2876: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_ssl.o'
objs/Makefile:3835: warning: overriding recipe for target 'objs/addon/src/ngx_http_lua_log_ringbuf.o'
objs/Makefile:2883: warning: ignoring old recipe for target 'objs/addon/src/ngx_http_lua_log_ringbuf.o'
cc -c -I/www/server/nginx/src/build/luajit-root/www/server/nginx/luajit/include/luajit-2.1 -I/www/server/nginx/src/build/luajit-root/www/server/nginx/luajit/include/luajit-2.1 -I/www/server/nginx/src/build/luajit-root/www/server/nginx/luajit/include/luajit-2.1 -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g -O2 -Wno-error -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I ../ngx_devel_kit-0.3.3/objs -I objs/addon/ndk -I ../ngx_lua-0.10.26/src/api -I ../ngx_stream_lua-0.0.14/src/api -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/lua_nginx_module/src/api -I /www/server/nginx/src/pcre-8.43 -I /www/server/nginx/src/openssl/.openssl/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../ngx_devel_kit-0.3.3/src -I ../ngx_devel_kit-0.3.3/src -I ../ngx_devel_kit-0.3.3/objs -I objs/addon/ndk -I /www/server/nginx/src/build/luajit-root/www/server/nginx/luajit/include/luajit-2.1 -I /www/server/nginx/src/ngx_devel_kit/src -I /www/server/nginx/src/ngx_devel_kit/src -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/build/luajit-root/www/server/nginx/luajit/include/luajit-2.1 -I src/stream -I /www/server/nginx/src/build/luajit-root/www/server/nginx/luajit/include/luajit-2.1 \
-o objs/addon/src/ngx_http_lua_headers_in.o \
/www/server/nginx/src/lua_nginx_module/src/ngx_http_lua_headers_in.c
In file included from /usr/include/dlfcn.h:24,
from src/os/unix/ngx_linux_config.h:58,
from src/core/ngx_config.h:26,
from /www/server/nginx/src/lua_nginx_module/src/ddebug.h:11,
from /www/server/nginx/src/lua_nginx_module/src/ngx_http_lua_headers_in.c:10:
/www/server/nginx/src/lua_nginx_module/src/ngx_http_lua_headers_in.c:162:50: error: ‘ngx_http_headers_in_t’ {aka ‘struct <anonymous>’} has no member named ‘cookies’; did you mean ‘cookie’?
162 | offsetof(ngx_http_headers_in_t, cookies),
| ^~~~~~~
make[2]: *** [objs/Makefile:3569: objs/addon/src/ngx_http_lua_headers_in.o] Error 1
make[2]: Leaving directory '/www/server/nginx/src/build/nginx-1.25.3'
make[1]: *** [Makefile:10: build] Error 2
make[1]: Leaving directory '/www/server/nginx/src/build/nginx-1.25.3'
make: *** [Makefile:9: all] Error 2
cp: cannot stat '/www/server/nginx/lualib/*': No such file or directory
========================================================
Ubuntu 20.04.3 LTS
\l
Bit:64 Mem:23989M Core:4 gcc:9.4.0 cmake:3.16.3
Linux 5.15.0-1081-oracle aarch64
ERROR: nginx-1.25.3.2 installation failed.



 🔍 报错的根本原因
具体的报错 error: ‘ngx_http_headers_in_t’ has no member named ‘cookies’ 是因为 Nginx 1.25+ 更改了内部 C API，移除了 cookies 数组。
OpenResty 1.27 使用了较新的 Nginx 核心，并且自带了兼容的 Lua 模块。但是，由于你之前可能安装过 WAF（防火墙）或其他 Lua 插件，宝塔的附加配置文件（nginx_configure.pl）强制脚本去下载并编译一个过时的外部版本 lua-nginx-module (v0.10.13)。编译器尝试同时构建内置和外置的模块，导致了配方冲突警告（recipe warnings）和致命的 cookies 结构体报错。
🛠️ 如何修改 nginx.sh 脚本下载安装脚本。https://dg2.bt.cn/install/3/nginx.sh
我们需要修改脚本，防止它在安装 OpenResty 时强行注入过时的外部 Lua 模块。
请使用 nano 或 vim 等编辑器打开你的脚本（nginx.sh），并进行以下两处修改：
修改 1：在 OpenResty 安装过程中剥离冲突的模块
找到以下代码块（大约在第 320 行，位于 Install_Configure() 函数内）：

```Bash

[ -f "/www/server/panel/install/nginx_configure.pl" ] && ADD_EXTENSION=$(cat /www/server/panel/install/nginx_configure.pl)
    if [ -f "/usr/local/lib/libjemalloc.so" ] && [ -z "${ARM_CHECK}" ] && [ -z "${JEM_CHECK}" ]; then
        jemallocLD="--with-ld-opt="-ljemalloc""
    fi
```



将其修改为：
```Bash

[ -f "/www/server/panel/install/nginx_configure.pl" ] && ADD_EXTENSION=$(cat /www/server/panel/install/nginx_configure.pl)
    
    # 修复 OpenResty 内置 Lua 模块与宝塔外置 Lua 模块冲突导致编译失败的问题
    if [ "${version}" == "openresty" ] || [ "${version}" == "openresty127" ]; then
        ADD_EXTENSION=$(echo "$ADD_EXTENSION" | sed 's/--add-module=[^ ]*lua_nginx_module[^ ]*//g')
        ADD_EXTENSION=$(echo "$ADD_EXTENSION" | sed 's/--add-module=[^ ]*ngx_devel_kit[^ ]*//g')
    fi

    if [ -f "/usr/local/lib/libjemalloc.so" ] && [ -z "${ARM_CHECK}" ] && [ -z "${JEM_CHECK}" ]; then
        jemallocLD="--with-ld-opt="-ljemalloc""
    fi
```



修改 2：更新后备 Lua 模块版本
找到以下代码块（大约在第 282 行，位于 Download_Src() 函数内）：
```Bash

#lua_nginx_module
    LuaModVer="0.10.13"
    if [ "${version}" == "1.23" ] || [ "${version}" == "1.24" ] || [ "${version}" == "tengine" ] ||  [ "${version}" == "1.25" ] || [ "${version}" == "1.26" ] || [ "${version}" == "1.27" ] || [ "${version}" == "1.28" ] || [ "${version}" == "1.29" ];then
        LuaModVer="0.10.24"
    fi
```



将其修改为：（我们将 OpenResty 版本添加到条件判断中，以确保如果脚本需要下载外置模块时，默认使用较新的版本）。
```bash

#lua_nginx_module
    LuaModVer="0.10.13"
    if [ "${version}" == "1.23" ] || [ "${version}" == "1.24" ] || [ "${version}" == "tengine" ] ||  [ "${version}" == "1.25" ] || [ "${version}" == "1.26" ] || [ "${version}" == "1.27" ] || [ "${version}" == "1.28" ] || [ "${version}" == "1.29" ] || [ "${version}" == "openresty" ] || [ "${version}" == "openresty127" ];then
        LuaModVer="0.10.24"
    fi
```



🚀 执行手动安装
保存对 nginx.sh 的修改后，你必须在服务器的 SSH 终端中运行安装命令。这样它就会使用你修改过的本地文件，而不是从宝塔服务器下载未修复的副本。
运行以下命令：
```Bash

bash nginx.sh install openresty127
```
2、启动报错：
nginx: [emerg] open() "/www/server/nginx/conf/mime.types" failed (2: No such file or directory) in /www/server/nginx/conf/nginx.conf:24nginx: [emerg] open() "/www/server/nginx/conf/fastcgi.conf" failed (2: No such file or directory) in /www/server/nginx/conf/enable-php.conf:6

原因： 这是一个致命错误（emerg），直接导致了 Nginx 无法启动。在宝塔环境替换或链接 OpenResty 配置文件目录时，基础的 mime.types、fastcgi.conf、fastcgi_params、没有被正确复制过来。解决方案：
```bash
wget -O /www/server/nginx/conf/mime.types https://raw.githubusercontent.com/nginx/nginx/master/conf/mime.types
wget -O /www/server/nginx/conf/fastcgi.conf https://raw.githubusercontent.com/nginx/nginx/master/conf/fastcgi.conf
wget -O /www/server/nginx/conf/fastcgi_params https://raw.githubusercontent.com/nginx/nginx/master/conf/fastcgi_params
```





