今天想给我Mac装一个OpenResty环境,brew install openresty提示找不到Openssl库。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
➜  ~ brew install openresty
...
checking for OpenSSL library ... not found
checking for OpenSSL library in /usr/local/ ... not found
checking for OpenSSL library in /usr/pkg/ ... not found
checking for OpenSSL library in /opt/local/ ... not found

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

解决方法:

brew edit openresty修改下边两行

1
2
    cc_opt = "-I#{HOMEBREW_PREFIX}/include -I#{Formula["pcre"].opt_include} -I#{Formula["openresty/brew/openresty-openssl111"].opt_include}"
    ld_opt = "-L#{HOMEBREW_PREFIX}/lib -L#{Formula["pcre"].opt_lib} -L#{Formula["openresty/brew/openresty-openssl111"].opt_lib}"

修改为

1
2
    cc_opt = "-I#{Formula["pcre"].opt_include} -I#{Formula["openresty/brew/openresty-openssl111"].opt_include}"
    ld_opt = "-L#{Formula["pcre"].opt_lib} -L#{Formula["openresty/brew/openresty-openssl111"].opt_lib}"

重新安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
➜ ~ brew install openresty
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.

==> Installing openresty from openresty/brew
==> Downloading https://openresty.org/download/openresty-1.17.8.2.tar.gz
Already downloaded: /Users/xnile/Library/Caches/Homebrew/downloads/b00ed84dc96875bccc0bf09c1858cde097f6ec7cc2296c26bafa37e97f743c0e--openresty-1.17.8.2.tar.gz
==> ./configure -j8 --prefix=/usr/local/Cellar/openresty/1.17.8.2_1 --pid-path=/usr/local/var/run/openresty.pid --lock-path=/usr/local/var/run/openresty.l
==> make
==> make install
==> Caveats
To have launchd start openresty/brew/openresty now and restart at login:
  brew services start openresty/brew/openresty
Or, if you don't want/need a background service you can just run:
  openresty
==> Summary
🍺  /usr/local/Cellar/openresty/1.17.8.2_1: 301 files, 6.6MB, built in 1 minute 2 seconds

参考

https://stackoverflow.com/questions/3939651/how-do-i-modify-a-homebrew-formula