MAMP 安装 MongoDB 扩展

  1. 安装 homebrew

  2. 确定已安装 pkg-config

$ where pkg-config


pkg-config not found

则先使用 brew install pkg-config 进行安装

  1. 安装最新的 OpenSSL

macOS 默认的 OpenSSL 版本太低,编译时需要版本高于1.0.1才可,so just install the lastest one.

$ brew install openssl
==> Downloading
Already downloaded: /Users/mrasong/Library/Caches/Homebrew/openssl-1.0.2l.sierra.bottle.tar.gz
==> Pouring openssl-1.0.2l.sierra.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in

and run

This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

==> Summary
  /usr/local/Cellar/openssl/1.0.2l: 1,709 files, 12.2MB


vi ~/.zshrc 或者 vi ~/.bash_profile


export PATH=/usr/local/opt/openssl/bin:$PATH
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

source ~/.zshrc 或者 source ~/.bash_profile

  1. pecl 安装
pecl install mongodb
  1. 修改 php.ini,加入,重启服务,完成。