nginx安装时,make编译可能会出现的错误问题

 更新时间:2024年06月06日 11:39:30   作者:学前端搞口饭吃  
这篇文章主要介绍了nginx安装时,make编译可能会出现的错误问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

第一个,报错

src/core/ngx_murmurhash.c: In function ‘ngx_murmur_hash2’:
src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
h ^= data[2] << 16;
^~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: note: here
case 2:
^~~~
src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
h ^= data[1] << 8;
^~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: note: here
case 1:
^~~~
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:473: objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory ‘/root/nginx-1.10.1‘
make: *** [Makefile:8: build] Error 2

分析原因:

是将警告当成了错误处理,打开 nginx的安装目录/objs/Makefile,去掉CFLAGS中的-Werror,再重新make

  • -Wall 表示打开gcc的所有警告
  • -Werror,它要求gcc将所有的警告当成错误进行处理

第二个,make出现的错误

src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:36:7: error: ‘struct crypt_data’ has no member named ‘current_salt’
cd.current_salt[0] = ~salt[0];
^
make[1]: *** [objs/Makefile:774: objs/src/os/unix/ngx_user.o] Error 1
make[1]: Leaving directory ‘/root/nginx-1.10.1‘
make: *** [Makefile:8: build] Error 2

这里提示我们struct crypt_data’没有名为‘current_salt’的成员:cd.current_salt[0] = ~salt[0];

最好的办法是换一个版本,因为条件限制,我们就进到源码里把这行直接注释掉好了。

# vim src/os/unix/ngx_user.c进入里面注释掉36行

第三个错误,openssl版本错误

src/event/ngx_event_openssl.c: In function ‘ngx_ssl_dhparam’:
src/event/ngx_event_openssl.c:954:11: error: dereferencing pointer to incomplete type ‘DH’ {aka ‘struct dh_st’}
dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
^~
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_connection_error’:
src/event/ngx_event_openssl.c:1941:21: error: ‘SSL_R_NO_CIPHERS_PASSED’ undeclared (first use in this function); did you mean ‘SSL_R_NO_CIPHERS_SPECIFIED’?
|| n == SSL_R_NO_CIPHERS_PASSED /* 182 */
^~~~~~~~~~~~~~~~~~~~~~~
SSL_R_NO_CIPHERS_SPECIFIED
src/event/ngx_event_openssl.c:1941:21: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [objs/Makefile:816: objs/src/event/ngx_event_openssl.o] Error 1
make[1]: Leaving directory ‘/root/nginx-1.10.1‘
make: *** [Makefile:8: build] Error 2

原因:

由于默认使用了openssl 1.1.x 版本,导致的API不一致引起

解决:

直接安装openssl1.0版本

wget http://www.openssl.org/source/openssl-1.1.0e.tar.gz //下载openssl
[root@iZgt88z6l1kvd7Z ~]# tar -zxvf openssl-1.1.0e.tar.gz //解压
[root@iZgt88z6l1kvd7Z ~]# cd openssl-1.1.0e/ &&./config shared zlib --prefix=/usr/local/openssl && make && make install 进入目录把openssl编译安装到 /usr/local/openssl 下
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# ./config -t
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# make depend //一种度makefile的规则,通过扫描仪个目录下的所有C\C++ 代码,从而判专断出文件之间的依赖关系,如a.cc文件中调用了b.h(如以形势include<b.h>),如果之后a.cc文件被改动,那 么只需要重新编属译a.cc文件,不需要编译b.h文件。否则所有的文件都需要重新编译。
[root@localhost openssl-1.1.0e]# cd /usr/local
[root@iZgt88z6l1kvd7Z local]# ln -s openssl ssl
[root@iZgt88z6l1kvd7Z local]# echo "/usr/local/openssl/lib" >>/etc/ld.so.conf
[root@iZgt88z6l1kvd7Z local]# cd /root/openssl-1.1.0e注意每个人的目录都是不一样的,我这里是root下的openssl,至于其他人看自己情况,切换目录
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# ldconfig
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# echo $?
0
[root@iZgt88z6l1kvd7Z openssl-1.1.0e]# echo "PATH=$PATH:/usr/local/openssl/bin" >> /etc/profile && source /etc/profile

然后重新进入nginx-1.9.9执行[root@iZwz967a5gqt3aqi2g3pbkZ nginx-1.9.9]# ./configure --prefix=/usr/local/nginx --add-module=/root/nginx-1.9.9/headers-more-nginx-module-0.33 --with-http_stub_status_module --with-http_ssl_module注意,我这里的是这条命令,至于你们的./configure……就看你们自身情况

重新make一下哎

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • Linux中Nginx的防盗链和优化的实现代码

    Linux中Nginx的防盗链和优化的实现代码

    今天是周末小编在值班哈,很开森,工作使我快乐,本文重点给大家介绍Linux中Nginx的防盗链和优化问题及实现代码,需要的朋友跟随小编一起看看吧
    2021-06-06
  • Nginx rewrite正则匹配重写的方法示例

    Nginx rewrite正则匹配重写的方法示例

    这篇文章主要介绍了Nginx rewrite正则匹配重写的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-10-10
  • Nginx 配置 WebSocket 代理的操作过程

    Nginx 配置 WebSocket 代理的操作过程

    这篇文章主要介绍了Nginx 配置 WebSocket 代理的操作过程,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧
    2024-04-04
  • 使用nginx+tomcat+keepalived实现高可用的详细步骤

    使用nginx+tomcat+keepalived实现高可用的详细步骤

    这篇文章主要介绍了nginx+tomcat+keepalived实现高可用,包括安装nginx服务的步骤,详细介绍了安装keepalived的方法,对nginx+tomcat+keepalived高可用相关知识感兴趣的朋友一起看看吧
    2022-03-03
  • 详解Nginx 静态文件服务配置及优化

    详解Nginx 静态文件服务配置及优化

    这篇文章主要介绍了Nginx 静态文件服务配置及优化,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2019-05-05
  • Nginx中的proxy_set_header核心参数解析

    Nginx中的proxy_set_header核心参数解析

    文章详解Nginx中proxy_set_header指令的语法与用途,涵盖设置Host头、传递真实IP、协议信息、连接控制、CORS支持、自定义头及缓存管理,强调需注意指令位置、空值处理和特殊头格式,感兴趣的朋友跟随小编一起看看吧
    2025-08-08
  • Nginx构建Tomcat集群的操作方法

    Nginx构建Tomcat集群的操作方法

    nginx是一款自由的、开源的、高性能的HTTP服务器和反向代理服务器;同时也是一个IMAP、POP3、SMTP代理服务器,这篇文章主要介绍了Nginx构建Tomcat集群的问题,需要的朋友可以参考下
    2022-01-01
  • Nginx 禁用静态文件缓存的配置方法

    Nginx 禁用静态文件缓存的配置方法

    禁用缓存可能会导致性能下降,因为每次请求都需要从后端服务器获取文件,因此,你需要根据具体情况权衡利弊并做出决策,这篇文章给大家介绍Nginx 禁用静态文件缓存的方法,感兴趣的朋友一起看看吧
    2024-02-02
  • 详解nginx服务器中的安全配置

    详解nginx服务器中的安全配置

    本篇文章主要介绍了nginx服务器中的安全配置,较为详细的分析了nginx服务器中的安全配置与相关操作注意事项,需要的朋友可以参考下。
    2016-10-10
  • Nginx如何自动封禁可疑Ip

    Nginx如何自动封禁可疑Ip

    这篇文章主要介绍了Nginx如何自动封禁可疑Ip问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2025-06-06

最新评论