Nginx编译找不到OpenSSL library
基本情况
因为需要使用https模块,因此在编译Nginx时添加了–with-http_ssl_module。结果编译过程中报错。
checking for OpenSSL library ... not found
checking for OpenSSL library in /usr/local/ ... not found
checking for OpenSSL library in /usr/pkg/ ... not found
checking for OpenSSL library in /opt/local/ ... not found
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
可是openssl-devel已经安装了,通过rpm命令也能找到
[root@fc-proxy nginx-1.23.3]# which openssl
/usr/bin/openssl
[root@fc-proxy nginx-1.23.3]# rpm -qa | grep openssl
openssl-1.0.2k-25.el7_9.x86_64
openssl-libs-1.0.2k-25.el7_9.x86_64
openssl-devel-1.0.2k-25.el7_9.x86_64
谷歌得到的答案大多数归结于两点:
- 没安装openssl-devel, 可是我已经装了呀
- 编译安装openssl并指定路径,nginx编译时添加–with-openssl,可是我已经装了呀,为啥要再装一次
问题解决
直到看到这篇文章:nginx升级及遇到的问题error: SSL modules解决方法
看起来应该是编译时一些文件没有找到,通过find命令查找一下 ssl.h , libssl.a , libcrypto.a 这几个文件
[root@fc-proxy nginx-1.23.3]# find / -name ssl.h
/root/openssl-1.1.1q/include/openssl/ssl.h
/usr/include/openssl/ssl.h
/usr/local/include/openssl/ssl.h
[root@fc-proxy lib]# find / -name libssl.a
/root/openssl-1.1.1q/libssl.a
/usr/local/lib64/libssl.a
[root@fc-proxy lib]# find / -name libcrypto.a
/root/openssl-1.1.1q/libcrypto.a
/usr/local/lib64/libcrypto.a
看起来相关的文件都在 /root/openssl-1.1.1q ,编译时添加--with-http_ssl_module=/root/openssl-1.1.1q
[root@fc-proxy nginx-1.23.3]# ./configure --with-http_ssl_module --with-openssl=/root/openssl-1.1.1q
……
[root@fc-proxy nginx-1.23.3]# make&& make install
……
顺利编译通过,问题解决。