尚品宅配范晓芸 发表于 2024-6-11 19:44:19

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 << 16;^~~~~~~~~~~~~~src/core/ngx_murmurhash.c:38:5: note: herecase 2:^~~~src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]h ^= data << 8;^~~~~~~~~~~~~src/core/ngx_murmurhash.c:40:5: note: herecase 1:^~~~cc1: all warnings being treated as errorsmake: *** Error 1make: Leaving directory ‘/root/nginx-1.10.1‘make: *** 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 = ~salt;^make: *** Error 1make: Leaving directory ‘/root/nginx-1.10.1‘make: *** Error 2这里提示我们struct crypt_data’没有名为‘current_salt’的成员:cd.current_salt = ~salt;
最好的办法是换一个版本,因为条件限制,我们就进到源码里把这行直接注释掉好了。
# 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_SPECIFIEDsrc/event/ngx_event_openssl.c:1941:21: note: each undeclared identifier is reported only once for each function it appears inmake: *** Error 1make: Leaving directory ‘/root/nginx-1.10.1‘make: *** Error 2原因:
由于默认使用了openssl 1.1.x 版本,导致的API不一致引起
解决:
直接安装openssl1.0版本
wget http://www.openssl.org/source/openssl-1.1.0e.tar.gz //下载openssl# tar -zxvf openssl-1.1.0e.tar.gz //解压# cd openssl-1.1.0e/ &&./config shared zlib --prefix=/usr/local/openssl && make && make install 进入目录把openssl编译安装到 /usr/local/openssl 下# ./config -t# make depend //一种度makefile的规则,通过扫描仪个目录下的所有C\C++ 代码,从而判专断出文件之间的依赖关系,如a.cc文件中调用了b.h(如以形势include<b.h>),如果之后a.cc文件被改动,那 么只需要重新编属译a.cc文件,不需要编译b.h文件。否则所有的文件都需要重新编译。# cd /usr/local# ln -s openssl ssl# echo "/usr/local/openssl/lib" >>/etc/ld.so.conf# cd /root/openssl-1.1.0e注意每个人的目录都是不一样的,我这里是root下的openssl,至于其他人看自己情况,切换目录# ldconfig# echo $?0# echo "PATH=$PATH:/usr/local/openssl/bin" >> /etc/profile && source /etc/profile
然后重新进入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一下哎

总结

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

来源:https://www.jb51.net/server/322329c4d.htm
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: nginx安装时,make编译可能会出现的错误问题