Using pecl to install the Mongodb driver on OS X El Capitan (v10.11.1)
I managed to get around this by installing OpenSSL using Homebrew (as suggested here):
$ brew install openssl$ brew link openssl --force
Then
$ sudo pecl install mongodb
Do this
$ cd /usr/local/include $ ln -s ../opt/openssl/include/openssl
I recommend using http://phpbrew.github.io/phpbrew/ for this type of thing. It let's you easily install any extensions to any php version you require.
When installing a new version of php, I usually keep an eye on the log while it compiles. There might be dependencies that need installing first. Also, make sure you have an updated version of homebrew installed.