I’m on El Capitan 10.11.6 and i had the issue while installing manually the mongodb php extension.
I solved it following the indications of @user7059092 about the configure stage :
$./configure LDFLAGS='-L/usr/local/opt/openssl/lib' CPPFLAGS='-I/usr/local/opt/openssl/include'