openssl源码安装后,编译nginx-1.9.7或者openresty找不到OpenSSL的解决办法

时间:2022-11-06 04:41:52

问题:nginx编译找不到openssl

现象:源码安装openssl的目录是/usr/local/ssl/

就算把/usr/local/ssl/lib 添加到 /etc/ld.so.conf内,并且ldconfig -v,发现nginx编译时依然报找不到openssl的错误,如下

#./configure --with-http_ssl_modul

--------------------------------------------------------------

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库文件。

上面红色字体的部分就是问题的原因所在,nginx会去红色字体的几个目录下找openssl库,而默认安装的路径是/usr/local/ssl

解决办法:

把/usr/local/ssl/lib/目录下的文件拷贝一份到以上红色路径的lib目录下即可,如cp /usr/local/ssl/lib/* /usr/local/lib/


之后再编译nginx或者openresty就正常了。


附:

或者可以使用./configure --with-openssl=your_openssl_source_dir编译。