当前位置: 代码网 > 服务器>服务器>Nginx > nginx安装时,make编译可能会出现的错误问题

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

2024年06月17日 Nginx 我要评论
第一个,报错src/core/ngx_murmurhash.c: in function ‘ngx_murmur_hash2’:src/core/ngx_murmurhash.

第一个,报错

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一下哎

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com