编译nginx时openssl报错的解决方案

出现提示错误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

分析原因:由于yum默认使用了openssl 1.1.x 版本,导致的API不一致引起的

解决:

直接安装openssl1.0版本
wget http://www.openssl.org/source/openssl-1.1.0e.tar.gz
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
ldconfig
echo "PATH=$PATH:/usr/local/openssl/bin" >> /etc/profile && source /etc/profile
编译nginx时openssl报错的解决方案

好嘞,查看版本 ,OK

我们再次进入nginx下

./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.8 --with-openssl=../opensll-1.1.0e

注意这里还是要把objs/Makefile下的werror去掉

然后启动一下nginx

/usr/local/nginx/sbin/nginx

查看一下进程和端口是否开启

编译nginx时openssl报错的解决方案

看看chrome能不能打开nginx的网页

编译nginx时openssl报错的解决方案

OK

上一篇:学习Nginx看这篇就够了


下一篇:dsg_16 nginx