[GH-ISSUE #74] 宝塔Nginx安装出错 #52

Closed
opened 2026-03-04 12:18:28 +03:00 by kerem · 25 comments
Owner

Originally created by @Rayzggz on GitHub (Dec 12, 2021).
Original GitHub issue: https://github.com/ADD-SP/ngx_waf/issues/74

  • 如何触发错误。
    使用宝塔安装nginx的时候

  • ngx_waf 的版本/分支。
    Current 版

  • nginx -V 命令的输出内容。
    未安装

  • 调试日志(如何获取调试日志)。
    未安装

  • 出错时 shell 的输出内容。

checking for uthash library ... not found
./configure: error: the ngx_http_waf_module module requires the uthash library.

Please run:
cd /www/server/nginx/src/ngx_waf
&& git clone -b v2.3.0 https://github.com/troydhanson/uthash.git lib/uthash
&& cd /www/server/nginx/src

可以提供的信息

  • 操作系统,包括名称和版本。
    CentOS 7.9.2009

我尝试使用 yum install uthash-devel 安装 但是无效

此外,经过检查,在nginx安装过程中uthash是按照前置脚本成功clone到 /www/server/nginx/src/ngx_waf/uthash 目录的


此外,在执行文档的 “在 shell 中运行命令” 的时候,出现了一些错误
根据报错和官方文档我安装了一些其他依赖解决了问题
yum install libtool
yum install https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/23/x86_64/b/bison-3.0.4-3.fc23.x86_64.rpm
yum install gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel doxygen zlib-devel pcre-devel

参考: https://github.com/SpiderLabs/ModSecurity/wiki/Compilation-recipes-for-v3.x#centos-7-minimal

可以在文档中补充一些这些依赖

Originally created by @Rayzggz on GitHub (Dec 12, 2021). Original GitHub issue: https://github.com/ADD-SP/ngx_waf/issues/74 * 如何触发错误。 使用宝塔安装nginx的时候 * ngx_waf 的版本/分支。 Current 版 * `nginx -V` 命令的输出内容。 未安装 * 调试日志([如何获取调试日志](#如何获取调试日志))。 未安装 * 出错时 `shell` 的输出内容。 checking for uthash library ... not found ./configure: error: the ngx_http_waf_module module requires the uthash library. Please run: cd /www/server/nginx/src/ngx_waf \ && git clone -b v2.3.0 https://github.com/troydhanson/uthash.git lib/uthash \ && cd /www/server/nginx/src ## 可以提供的信息 * 操作系统,包括名称和版本。 CentOS 7.9.2009 我尝试使用 yum install uthash-devel 安装 但是无效 此外,经过检查,在nginx安装过程中uthash是按照前置脚本成功clone到 /www/server/nginx/src/ngx_waf/uthash 目录的 -------------------------------- 此外,在执行文档的 “在 shell 中运行命令” 的时候,出现了一些错误 根据报错和官方文档我安装了一些其他依赖解决了问题 yum install libtool yum install https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/23/x86_64/b/bison-3.0.4-3.fc23.x86_64.rpm yum install gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel doxygen zlib-devel pcre-devel 参考: https://github.com/SpiderLabs/ModSecurity/wiki/Compilation-recipes-for-v3.x#centos-7-minimal 可以在文档中补充一些这些依赖
kerem 2026-03-04 12:18:28 +03:00
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

文档错误,应该将 uthash 下载到 ngx_waf/lib 目录下。

<!-- gh-comment-id:991869084 --> @ADD-SP commented on GitHub (Dec 12, 2021): 文档错误,应该将 `uthash` 下载到 `ngx_waf/lib` 目录下。
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

文档已更新,可清理浏览器缓存后再行访问,感谢对文档的补充。

<!-- gh-comment-id:991870703 --> @ADD-SP commented on GitHub (Dec 12, 2021): 文档已更新,可清理浏览器缓存后再行访问,感谢对文档的补充。
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

之前的检测都通过了

但是还是有报错

这个我就完全不知道怎么解决了
麻烦帮忙看看 谢谢

cc -c -I/usr/local/include/luajit-2.0/ -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g EMP_CC_OPT -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/lua_nginx_module/src/api -I pcre-8.43 -I /www/server/nginx/src/openssl/.openssl/include -I /usr/include/libxml2 -I objs
-o objs/src/core/ngx_log.o
src/core/ngx_log.c
cc -c -I/usr/local/include/luajit-2.0/ -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g EMP_CC_OPT -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/lua_nginx_module/src/api -I pcre-8.43 -I /www/server/nginx/src/openssl/.openssl/include -I /usr/include/libxml2 -I objs
-o objs/src/core/ngx_palloc.o
src/core/ngx_palloc.c
cc: error: EMP_CC_OPT: No such file or directory
cc: error: EMP_CC_OPT: No such file or directory
cc: error: EMP_CC_OPT: No such file or directory
make[1]: *** [objs/src/core/nginx.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [objs/src/core/ngx_log.o] Error 1
make[1]: *** [objs/src/core/ngx_palloc.o] Error 1
make[1]: Leaving directory /www/server/nginx/src' make: *** [build] Error 2 make -f objs/Makefile install make[1]: Entering directory /www/server/nginx/src'
cc -c -I/usr/local/include/luajit-2.0/ -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g EMP_CC_OPT -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/lua_nginx_module/src/api -I pcre-8.43 -I /www/server/nginx/src/openssl/.openssl/include -I /usr/include/libxml2 -I objs
-o objs/src/core/nginx.o
src/core/nginx.c
cc: error: EMP_CC_OPT: No such file or directory

<!-- gh-comment-id:991904094 --> @Rayzggz commented on GitHub (Dec 12, 2021): 之前的检测都通过了 但是还是有报错 这个我就完全不知道怎么解决了 麻烦帮忙看看 谢谢 cc -c -I/usr/local/include/luajit-2.0/ -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g EMP_CC_OPT -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/lua_nginx_module/src/api -I pcre-8.43 -I /www/server/nginx/src/openssl/.openssl/include -I /usr/include/libxml2 -I objs \ -o objs/src/core/ngx_log.o \ src/core/ngx_log.c cc -c -I/usr/local/include/luajit-2.0/ -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g EMP_CC_OPT -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/lua_nginx_module/src/api -I pcre-8.43 -I /www/server/nginx/src/openssl/.openssl/include -I /usr/include/libxml2 -I objs \ -o objs/src/core/ngx_palloc.o \ src/core/ngx_palloc.c cc: error: EMP_CC_OPT: No such file or directory cc: error: EMP_CC_OPT: No such file or directory cc: error: EMP_CC_OPT: No such file or directory make[1]: *** [objs/src/core/nginx.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: *** [objs/src/core/ngx_log.o] Error 1 make[1]: *** [objs/src/core/ngx_palloc.o] Error 1 make[1]: Leaving directory `/www/server/nginx/src' make: *** [build] Error 2 make -f objs/Makefile install make[1]: Entering directory `/www/server/nginx/src' cc -c -I/usr/local/include/luajit-2.0/ -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g EMP_CC_OPT -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I /www/server/nginx/src/ngx_devel_kit/objs -I objs/addon/ndk -I /www/server/nginx/src/lua_nginx_module/src/api -I pcre-8.43 -I /www/server/nginx/src/openssl/.openssl/include -I /usr/include/libxml2 -I objs \ -o objs/src/core/nginx.o \ src/core/nginx.c cc: error: EMP_CC_OPT: No such file or directory
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

将编译参数中的 --with-cc-opt=$TEMP_CC_OPT 删除。

<!-- gh-comment-id:991906640 --> @ADD-SP commented on GitHub (Dec 12, 2021): 将编译参数中的 `--with-cc-opt=$TEMP_CC_OPT` 删除。
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

删掉应该不行,这样就缺了这个参数

checking for C99 features ... not found
./configure: error: the ngx_http_waf_module module requires the C99 features, make sure your C compiler supports and enables the C99 standard.

For gcc, you can enable the C99 standard by appending the parameter --with-cc-opt='-std=gnu99'.

<!-- gh-comment-id:991909175 --> @Rayzggz commented on GitHub (Dec 12, 2021): 删掉应该不行,这样就缺了这个参数 checking for C99 features ... not found ./configure: error: the ngx_http_waf_module module requires the C99 features, make sure your C compiler supports and enables the C99 standard. For gcc, you can enable the C99 standard by appending the parameter --with-cc-opt='-std=gnu99'.
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

试试 --with-cc-opt=\${TEMP_CC_OPT}

<!-- gh-comment-id:991909325 --> @ADD-SP commented on GitHub (Dec 12, 2021): 试试 `--with-cc-opt=\${TEMP_CC_OPT}`
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

现在是报这个

checking for int size ...
./configure: error: can not detect int size

我的是x86_64 的CPU

查到资料说是 --with-cc-opt='-m32 -march=i386 的问题
但是好像没加这个参数

<!-- gh-comment-id:991912688 --> @Rayzggz commented on GitHub (Dec 12, 2021): 现在是报这个 checking for int size ... ./configure: error: can not detect int size 我的是x86_64 的CPU 查到资料说是 --with-cc-opt='-m32 -march=i386 的问题 但是好像没加这个参数
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

你设置环境变量 $TEMP_CC_OPT 了么?

<!-- gh-comment-id:991914883 --> @ADD-SP commented on GitHub (Dec 12, 2021): 你设置环境变量 `$TEMP_CC_OPT` 了么?
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

设置了

<!-- gh-comment-id:991914991 --> @Rayzggz commented on GitHub (Dec 12, 2021): 设置了
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

稍等,我在重新测试确认

<!-- gh-comment-id:991915096 --> @Rayzggz commented on GitHub (Dec 12, 2021): 稍等,我在重新测试确认
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

没错
我使用文档的 --with-cc-opt=$TEMP_CC_OPT
是可以 checking for int size ... 4 bytes

<!-- gh-comment-id:991915371 --> @Rayzggz commented on GitHub (Dec 12, 2021): 没错 我使用文档的 --with-cc-opt=$TEMP_CC_OPT 是可以 checking for int size ... 4 bytes
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

echo $TEMP_CC_OPT 的输出是?

<!-- gh-comment-id:991915427 --> @ADD-SP commented on GitHub (Dec 12, 2021): `echo $TEMP_CC_OPT` 的输出是?
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

[root@localhost ~]# echo $TEMP_CC_OPT
-std=gnu99 -Wno-sign-compare

<!-- gh-comment-id:991915492 --> @Rayzggz commented on GitHub (Dec 12, 2021): [root@localhost ~]# echo $TEMP_CC_OPT -std=gnu99 -Wno-sign-compare
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

没错
我把 --with-cc-opt=${TEMP_CC_OPT} 改成 --with-cc-opt=$TEMP_CC_OPT
再次出现

checking for int size ...
./configure: error: can not detect int size
<!-- gh-comment-id:991915821 --> @Rayzggz commented on GitHub (Dec 12, 2021): 没错 我把 --with-cc-opt=\${TEMP_CC_OPT} 改成 `--with-cc-opt=$TEMP_CC_OPT` 再次出现 ``` checking for int size ... ./configure: error: can not detect int size ```
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

$TEMP_CC_OPT 的值改为 "'-std=gnu99 -Wno-sign-compare'"(注意单引号),然后 --with-cc-opt=\${TEMP_CC_OPT}

<!-- gh-comment-id:991915983 --> @ADD-SP commented on GitHub (Dec 12, 2021): 把 `$TEMP_CC_OPT` 的值改为 "'-std=gnu99 -Wno-sign-compare'"(注意单引号),然后 `--with-cc-opt=\${TEMP_CC_OPT}`。
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

-std=gnu99 -Wno-sign-compare 这个貌似和原本没有变化鸭

<!-- gh-comment-id:991916434 --> @Rayzggz commented on GitHub (Dec 12, 2021): -std=gnu99 -Wno-sign-compare 这个貌似和原本没有变化鸭
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

有的,原本是单引号包裹,现在是双引号在外部包裹,首尾还有一对单引号。

<!-- gh-comment-id:991916652 --> @ADD-SP commented on GitHub (Dec 12, 2021): 有的,原本是单引号包裹,现在是双引号在外部包裹,首尾还有一对单引号。
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

明白😊

<!-- gh-comment-id:991916809 --> @Rayzggz commented on GitHub (Dec 12, 2021): 明白😊
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

不行,现在卡在更前面了

checking for C compiler ... found
+ using GNU C compiler
checking for --with-ld-opt="-ljemalloc" ... not found
./configure: error: the invalid value in --with-ld-opt="-ljemalloc"

<!-- gh-comment-id:991918224 --> @Rayzggz commented on GitHub (Dec 12, 2021): 不行,现在卡在更前面了 ``` checking for C compiler ... found + using GNU C compiler checking for --with-ld-opt="-ljemalloc" ... not found ./configure: error: the invalid value in --with-ld-opt="-ljemalloc" ```
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

这里才刚刚clone完uthash 和 checking for OS

<!-- gh-comment-id:991918356 --> @Rayzggz commented on GitHub (Dec 12, 2021): 这里才刚刚clone完uthash 和 checking for OS
Author
Owner

@ADD-SP commented on GitHub (Dec 12, 2021):

我送宝塔的安装程序一张图。

image

改成 --with-cc-opt=-std=gnu99 试试,如果还是不行,建议找宝塔官方让他们修修自己的代码。

之前测试的时候就有这回事,宝塔的程序对编译参数处理不当。

<!-- gh-comment-id:991919467 --> @ADD-SP commented on GitHub (Dec 12, 2021): 我送宝塔的安装程序一张图。 ![image](https://user-images.githubusercontent.com/44437200/145718706-4098ff6e-7f4e-461d-be75-96255c2329d3.png) 改成 `--with-cc-opt=-std=gnu99` 试试,如果还是不行,建议找宝塔官方让他们修修自己的代码。 之前测试的时候就有这回事,宝塔的程序对编译参数处理不当。
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

可以了 非常感谢

宝塔杂七杂八的问题确实多,之前被宝塔的一些插件坑了好几次
现在都只敢作为一个方便的管理工具了,否则站点多配置挺麻烦的

<!-- gh-comment-id:991920918 --> @Rayzggz commented on GitHub (Dec 12, 2021): 可以了 非常感谢 宝塔杂七杂八的问题确实多,之前被宝塔的一些插件坑了好几次 现在都只敢作为一个方便的管理工具了,否则站点多配置挺麻烦的
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

Uploading 91A92191-4BA7-4F8C-A469-AD11E5DED7D2.jpeg…

还有一个小问题 这里应该缺了一个目录切换

<!-- gh-comment-id:991921406 --> @Rayzggz commented on GitHub (Dec 12, 2021): ![Uploading 91A92191-4BA7-4F8C-A469-AD11E5DED7D2.jpeg…]() 还有一个小问题 这里应该缺了一个目录切换
Author
Owner

@Rayzggz commented on GitHub (Dec 12, 2021):

宝塔面板
在 shell 中运行命令 部分

安装 ModSecurity v3 后

应该多一个目录切换

./configure --prefix=/usr/local/libmaxminddb
make -j$(nproc)
make install
# 安装 ModSecurity v3
cd /usr/local/src              增加这一行
git clone -b v3.0.5 https://github.com/SpiderLabs/ModSecurity.git
cd ModSecurity
chmod +x build.sh
./build.sh
git submodule init
<!-- gh-comment-id:991922219 --> @Rayzggz commented on GitHub (Dec 12, 2021): 宝塔面板 在 shell 中运行命令 部分 # 安装 ModSecurity v3 后 应该多一个目录切换 即 ``` ./configure --prefix=/usr/local/libmaxminddb make -j$(nproc) make install # 安装 ModSecurity v3 cd /usr/local/src 增加这一行 git clone -b v3.0.5 https://github.com/SpiderLabs/ModSecurity.git cd ModSecurity chmod +x build.sh ./build.sh git submodule init ```
Author
Owner

@ADD-SP commented on GitHub (Dec 15, 2021):

宝塔面板 在 shell 中运行命令 部分

安装 ModSecurity v3 后

应该多一个目录切换 即

./configure --prefix=/usr/local/libmaxminddb
make -j$(nproc)
make install
# 安装 ModSecurity v3
cd /usr/local/src              增加这一行
git clone -b v3.0.5 https://github.com/SpiderLabs/ModSecurity.git
cd ModSecurity
chmod +x build.sh
./build.sh
git submodule init

文档已更新,感谢。

<!-- gh-comment-id:994261567 --> @ADD-SP commented on GitHub (Dec 15, 2021): > 宝塔面板 在 shell 中运行命令 部分 > # 安装 ModSecurity v3 后 > > 应该多一个目录切换 即 > > ``` > ./configure --prefix=/usr/local/libmaxminddb > make -j$(nproc) > make install > # 安装 ModSecurity v3 > cd /usr/local/src 增加这一行 > git clone -b v3.0.5 https://github.com/SpiderLabs/ModSecurity.git > cd ModSecurity > chmod +x build.sh > ./build.sh > git submodule init > ``` 文档已更新,感谢。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ngx_waf#52
No description provided.