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

Windows下WAMP环境PHP5.6安装MongoDB PECL扩展后仍报错求助

Fixing "The MongoDB PECL extension has not been installed or enabled" on WAMP (PHP 5.6 x64)

Alright, let’s tackle this together—this is a super common issue with WAMP and older PHP versions like 5.6, and I’ve walked through it dozens of times. Here’s the step-by-step breakdown to get your MongoDB extension working:

1. Make sure you’re editing the correct php.ini file

WAMP loves to have multiple php.ini files floating around (one for Apache, one for CLI, sometimes more), and it’s way too easy to modify the wrong one. Here’s how to confirm which one matters:

  • Create a quick PHP file with this code:
    <?php phpinfo(); ?>
    
  • Open it in your browser, then look for the Loaded Configuration File line. This is the exact php.ini you need to edit—ignore any others.

2. Match your php.ini extension line to the DLL filename

For PHP 5.6, there are two distinct MongoDB extensions to watch out for:

  • The older legacy mongo extension: Uses php_mongo.dll (add extension=php_mongo.dll to your php.ini)
  • The newer, maintained mongodb extension: Uses php_mongodb.dll (add extension=php_mongodb.dll instead)
    Double-check the filename of the DLL you downloaded, then add the corresponding line near the other extension= entries in your php.ini.

3. Confirm the DLL is in the right folder

  • Go back to your phpinfo() output and find the extension_dir value—this is the exact folder where your MongoDB DLL needs to live.
  • Drop the DLL directly into this folder (no subfolders!) and make sure it’s a Thread Safe (TS) x64 build compiled with VC11. PHP 5.6 for Windows uses VC11, so extensions must match this compiler version to load properly.

4. Restart WAMP the right way

Don’t just click "Restart All Services" in the WAMP tray—sometimes Apache holds onto old settings. Instead:

  • Right-click the WAMP tray icon > Exit, wait 10 seconds, then re-open WAMP. This forces all services to fully reload the updated php.ini.

5. Install the required Visual C++ Redistributable

PHP 5.6 TS x64 is built with Microsoft Visual C++ 2012 (VC11), so you need the matching redistributable package to avoid hidden dependency errors:

  • Install the Microsoft Visual C++ 2012 Redistributable (x64). This fixes "missing DLL" issues that often don’t show up in the main error message but block the extension from loading.

6. Check the logs for hidden clues

If you’re still stuck, dig into the error logs—they’ll tell you exactly what’s wrong:

  • Apache error log: Found in [Your WAMP Folder]\logs\error.log
  • PHP error log: Look for the error_log path in phpinfo() to find its location
    You might see messages like "Cannot find php_mongodb.dll" or "Missing MSVCR110.dll" that point you straight to the fix.

7. Verify the extension loaded

After making changes and restarting WAMP, refresh your phpinfo() page and search for "mongodb" or "mongo". If you see a dedicated section for the extension, you’re good to go! If not, double-check all the steps above—9 times out of 10, it’s a filename/path mismatch or missing dependency.

内容的提问来源于stack exchange,提问作者akku

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:33:21