You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS环境下MAMP(PHP7.1.12)通过Brew安装MongoDB可行性咨询

PHP 7.1.12 + MAMP + MongoDB on macOS: Is It Feasible?

Hey there, great question—yes, this setup is feasible, but you’ll need to work around the fact that PHP 7.1 is end-of-life (EOL) and official package support has dropped off. Let’s walk through why your initial Brew attempts failed and how to fix it:

Why Brew Isn’t Working for You

Brew’s official PHP taps and extension repos prioritize actively supported PHP versions (7.4+ at the time of writing). The mongodb extension for PHP 7.1 was last updated in version 1.9.x (releases after 1.10.x require PHP 7.2+), and these older builds are no longer hosted in the default Brew taps.

Step-by-Step Fixes to Get MongoDB Working

Option 1: Install via PECL (Most Reliable Method)

PECL still hosts archived versions of the mongodb extension compatible with PHP 7.1. Here’s how to use it with your MAMP setup:

  • First, point your terminal to MAMP’s PHP 7.1.12 binary to avoid conflicts with system PHP:
    export PATH=/Applications/MAMP/bin/php/php7.1.12/bin:$PATH
    
  • Verify you’re using the correct PHP version:
    php -v
    
    You should see PHP 7.1.12 in the output.
  • Install the last compatible mongodb extension version (1.9.2):
    pecl install mongodb-1.9.2
    
  • Open your MAMP PHP 7.1.12 config file (usually at /Applications/MAMP/bin/php/php7.1.12/conf/php.ini) and add this line at the end to enable the extension:
    extension=mongodb.so
    
  • Restart MAMP’s Apache or PHP-FPM service, then verify the extension is loaded with:
    php -m | grep mongodb
    
    If you see mongodb in the list, you’re good to go.

Option 2: Use a Third-Party Brew Tap (Alternative)

Some community-maintained Brew taps still host older PHP extensions. While less reliable than PECL, you can try searching for taps that support PHP 7.1 extensions. Just make sure to vet the source for security before adding it to your system.

Important Note

PHP 7.1 reached end-of-life in December 2019, meaning it no longer receives security updates. If this is a production environment, strongly consider upgrading to a supported PHP version (7.4 or newer) to avoid vulnerabilities. But if you’re stuck on PHP 7.1.12 for legacy reasons, the PECL method above should get MongoDB up and running for you.

内容的提问来源于stack exchange,提问作者Lukáš Pícha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:14:32