7

I am trying to install the php mongo driver for OS X. I've tried following these instructions to no avail.

$ which pecl -> /usr/local/Cellar/php56/5.6.13_2/bin/pecl

$ sudo pecl install mongo -> full build results here but the problem the is the error:

In file included from /private/tmp/pear/install/mongo/io_stream.c:34:
/private/tmp/pear/install/mongo/contrib/php-ssl.h:33:10: fatal error: 'openssl/evp.h' file not found
#include <openssl/evp.h>

My Xcode command-line tools are up to date (I used $ xcode-select --install to be sure).

I'm sure how to fix this problem.

Community
  • 1
  • 1
RobertJoseph
  • 7,968
  • 12
  • 68
  • 113

4 Answers4

18

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
Ezekiel Victor
  • 3,877
  • 1
  • 27
  • 28
John J. Camilleri
  • 4,171
  • 5
  • 31
  • 41
  • 4
    Notably `mongo` is the deprecated package name; people should be using `mongodb`. The forced brew linking works also with the newer package `mongodb`. Thanks! – Ezekiel Victor May 09 '16 at 08:33
  • @EzekielVictor Saved my day! – Sibidharan Nov 09 '16 at 11:36
  • Sure thing... I submitted an edit now to update his answer. Probably should have done that to begin with. – Ezekiel Victor Nov 10 '16 at 00:03
  • This won't work anymore and should be unsafe. Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib – Chris Nov 17 '16 at 11:36
  • 2
    @EzekielVictor I updated to mac os Sierra and when I try execute brew install open ssl it says "Warning: openssl-1.0.2j already installed", and again when I execute brew link openssl --force it says "Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" Any idea how to get it work? – Ronak Shah Dec 03 '16 at 10:45
9

Do this

$ cd /usr/local/include 
$ ln -s ../opt/openssl/include/openssl
Uncoke
  • 1,832
  • 4
  • 26
  • 58
1

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.

David Wickström
  • 397
  • 3
  • 11
-1

You need to disable the Mac OSX El Capitán rootless mechanism:

  1. Boot with Cmd-R
  2. Open Terminal
  3. Type csrutil disable
  4. Reboot

On the Mac, You need to install Xcode, and build the symlink for the openssl comes with Xcode, i.e.

cd /usr/include;
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/openssl
Jake N
  • 10,535
  • 11
  • 66
  • 112
Alan Cruz
  • 137
  • 1
  • 3