11

Having a mare with this. I'm trying to install the latest PHP mongo DB Drivers. I've looked everywhere and tried everything suggested but it will not get passed this error:


In file included from /private/tmp/pear/install/mongodb/src/contrib/php-ssl.c:31:
/private/tmp/pear/install/mongodb/src/contrib/php-ssl.h:33:10: fatal error: 'openssl/evp.h' file not found
include <openssl/evp.h>
         ^
1 error generated.
make: *** [src/contrib/php-ssl.lo] Error 1
ERROR: `make' failed

My system / setup:

OS X El Capitain v 10.11.6
PHP 7.1.0
Apache

I'm using this command to install it: sudo pecl install mongodb

I've tried the:

$ brew install openssl
$ brew link openssl --force

but that no longer works...and any of the latest workarounds for that do not work either

I've even tried going "rootless" but to no avail.

5
  • I've been pulling my hair out for a whole week over this. Any help is appreciated! Nov 4, 2016 at 21:01
  • I'm still no further forward with this. Think I'm going to set up a dev server on a raspberry pi at this rate. Nov 5, 2016 at 8:24
  • I ended up getting annoyed and completely removing my Apache and PHP installation, and then reinstalling. All good now Nov 6, 2016 at 20:15
  • 1
    gave up...went back to ubuntu. Dec 13, 2016 at 22:25
  • Solutions below didn't work for me. Running on Catalina 10.15.6 Oct 2, 2020 at 23:17

2 Answers 2

30

This solution worked for me. If you don't already have openssl then first run brew install openssl. Then run:

$ cd /usr/local/include 
$ ln -s ../opt/openssl/include/openssl .
2
  • Worked for me too Jan 25, 2019 at 6:20
  • Worked for me on an unrelated build (promark3) which had the same error ('openssl/evp.h' file not found)
    – chesterbr
    Feb 22, 2022 at 0:19
2

Two things are required. The one suggested by @ierdna was what was required for me to work, but only after I performed the following

~$ brew install openssl
~$ brew info openssl

Do the exporting as told by brew

~$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
~$ export CPPFLAGS="-I/usr/local/opt/openssl/include"

Then do what ierdna tells you..

~$ cd /usr/local/include
~$ ln -s ../opt/openssl/include/openssl .

It worked for me immediately

1
  • please work on that edit queue
    – blkpingu
    Jan 6, 2022 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.