Nginx Cannot Find OpenSSL Development Headers

2019-02-04 09:21发布

问题:

When I run: rvmsudo passenger-install-nginx-module on my Mac to install nginx, the terminal prints:

Checking for OpenSSL development headers...
  Found: no

But I am certain I have openssl installed. which openssl returns /usr/local/openssl/bin/openssl and /usr/local/openssl/bin: is the first entry in my $PATH. My questions are:

  • Are the OpenSSL development headers included with the regular openssl install through homebrew?
  • If they aren't, where should I download them from?

回答1:

If brew link openssl --force gives you this message:

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

Try this:

$ brew doctor (now fix anything that it tells you to fix)
$ brew update
$ brew upgrade

Now let's install it:

$ brew install openssl

And now we'll link it into our public area so you don't have to figure out the magic environment variable to set while building your favorite OpenSSL-backed library:

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

All done! Enjoy



回答2:

If you are on Mac OS X El Capitan, Apple doesn't include openssl any more because of security problems openssl had, I have similar problem installing Passenger. brew just installs openssl itself without development headers.

If you are on an older version of Mac OS X than El Capitan, you can use: xcode-select --install which installs openssl development headers as well.

EDIT:

Updating brew and installing openssl and force linking openssl to brew version solved my problem:

$ brew update 
$ which openssl  
/usr/bin/openssl 
$ brew install openssl
$ brew link openssl --force 
$ which openssl 
/usr/local/bin/openssl