PHP Startup Unable to load dynamic library php_mongo.dll

50,552

Solution 1

Make sure you download the correct .DLL for your PHP installation. Good chance you're running apache x86, so download an x86 php_mongo.dll. Also if you're running PHP as an Apache module, make sure you pick the thread safe (ts) one and also pick this type of dll that matches the PHP version you're running.

The versions must match or else you will get a php startup error. Find these Mongo DLLs here.

I did this then I got an error libsasl.dll not found. I simply copied the libsasl.dll found in my PHP installation directory to the Apache installation directory (where httpd.exe is found). Then I restarted my Apache and it worked!

Solution 2

For anyone googling this in 2017, the PECL Package has been updated and is now found at http://pecl.php.net/package/mongodb/1.2.9/windows

and use:

extension=php_mongodb.dll 

instead of:

extension=php_mongo.dll

Solution 3

Copy C:\xampp\php\libsasl.dll to C:\xampp\apache\bin\, restart Apache and enjoy.

Solution 4

If you are still having problems after doing the above, do try older version drivers instead.

That is what worked for me on for my XAMPP/ PHP 5.5 on windows 8.

Older drivers can be found here: https://s3.amazonaws.com/drivers.mongodb.org/php/index.html

New drivers can be found here: http://pecl.php.net/package/mongo/1.5.5/windows

You may also want to visit : https://serverfault.com/questions/563867/mongodb-unable-to-load-driver-on-php

Solution 5

This is normally because we use 64 Bit supported DLL file 64 Bit system. But the wamp/xampp architecture could be 32 Bit. We need to use based on the wamp/xampp architecture not the windows architecture. So, try to find relevant version of DLL file to the wamp/xampp architecture. The solution in the below link worked like a charm to me,

http://grokbase.com/t/gg/mongodb-user/151xpk3fkr/php-5-6-3-with-mongodb-driver-unable-to-load-dynamic-library-not-a-valid-win32-application

This link helps you to find the wamp/xampp architecture, https://stackoverflow.com/a/22454865/4874281

Share:
50,552
blitzen12
Author by

blitzen12

Updated on August 04, 2020

Comments

  • blitzen12
    blitzen12 almost 4 years

    I'm a beginner for this. I'm trying to install mongodb driver on php.

    Platform: Windows 8.1 64bit.
    PHP 5.5.9
    Apache/2.4.7
    

    Followed the instruction here:http://php.net/manual/en/mongo.installation.php#mongo.installation.windows

    I've tried all php_mongo.dll file with VC11 and put in php/ext folder. and added extension=php_mongo.dll in php.ini file but when I tried to start apache in xampp controller I got an error.

        Php Startup: Unable to load dynamic library
      'C:\xampp\php\ext\php_mongo.dll' -%1 is not a valid Win32 application.
    

    I've already check my VC compilator version inside phpinfo() and it's stated there MSVC11 with architecture: x86.

    it would be nice if someone can help me. Thanks. appreciate it.

  • bjori
    bjori over 9 years
    The trick here is indeed to copy the libsasl.dll from the php folder to the apache binary folder
  • blitzen12
    blitzen12 over 9 years
    yeah. copying libsasl.dll to apache bin directory solved the problem.
  • Selva
    Selva almost 9 years
    @Bryan KIm can u help me to solve this question stackoverflow.com/questions/30910162/…
  • peter
    peter about 8 years
    The new drivers link at pecl mongo 1.5.5 worked for me.
  • suku
    suku over 7 years
    it didn't help. I am still getting the error, but I can see mongo loaded in phpinfo()
  • suku
    suku over 7 years
    it didn't help. I am still getting the error, but I can see mongo loaded in phpinfo()
  • Prashanth kumar
    Prashanth kumar over 6 years
    It worked for me, although there was already a "libsasl.dll" available in C:\xampp\apache/bin. I just replaced the copy from C:\xampp\php\libsasl.dll to C:\xampp\apache\bin\ and it did the trick
  • user5389726598465
    user5389726598465 almost 6 years
    Yes bitnami wamp turned out to be 32bit. Can't believe that worked.
  • Benten
    Benten about 4 years
    "make sure you pick the thread safe (ts) one and also pick this type of dll that matches the PHP version you're running." yes!
  • Arshit
    Arshit over 3 years
    please make sure check your php version and php_mongodb.dll file version