MongoDb PHP driver installation issue on wamp

前端 未结 5 643
执笔经年
执笔经年 2020-12-05 22:11

I have php of version 5.5.12 and wamp version 2.4.9 and PHP Extension Build as API20121212,TS,VC11 . I am using this dll \'php_mongo-1.5.5-5.5-vc11.dll\' (renamed to php_mon

相关标签:
5条回答
  • 2020-12-05 22:37

    Have you entered the .dll in your php.ini file (properly)?

    http://docs.mongodb.org/ecosystem/drivers/php/

    Scott

    0 讨论(0)
  • 2020-12-05 22:40

    If you still facing the problem follow bellow two rules:

    • Make sure you downloaded drivers from http://pecl.php.net/package/mongo
    • Try version 1.5.1 drivers (When I am writing this the latest driver version is 1.6.8 but 1.6.8 to 1.5.5 nothing is worked for me)
    0 讨论(0)
  • 2020-12-05 22:52

    I have never used MONGO, but I was interested to see if there where problems using it with WAMPServer so I did a quick install to prove it shoud work, and it does.

    Here is a list of what I did, I hope it helps you work out what you may have done wrong.

    First you have to download the Mongo Database manager itself and install it. Download from https://www.mongodb.org/downloads

    Updated Aug 2019: Download from here now

    So you can place the software yourself I would download the ZIP and NOT the .MSI this way you dont get your system messed with by the .msi developer and what they think should be done to your system and you are in complete control.

    Download the 32bit or 64 bit version to match your OS and WampServer(32/64) version you are running.

    Now the Install is just a case of extracting the files from the zip and placing them somewhere on your system. I suggest :-

    Copy the bin folder from the extract to c:\wamp\bin\mongo\mongox.y.z ( x.y.z to match the version of mongo you downloaded).

    Create a data folder under that folder, so c:\wamp\bin\mongo\mongox.y.z\data Create a data folder for your first database under that folder, so \wamp\bin\mongo\mongox.y.z\data\db

    Create a config file for mongo in c:\wamp\bin\mongo\mongox.y.z\mongod.cfg and add as a minimum these parameter :-

    NOTE: these are just params that will get it running, NOT A DEFINITIVE SET OF PARAMETERS!

    systemLog:
      destination: file
      path: "c:/wamp/logs/mongod.log"
      logAppend: true
      timeStampFormat: iso8601-local
    
    net:
      bindIp: 127.0.0.1
      port: 27017
    
    storage:
      dbPath: "c:/wamp/bin/mongo/mongo2.6.6/data"
      directoryPerDB: true
    

    Now if you want to have mongodb running as a service create a command file like so in the C:\wamp\bin\mongo\mongox.y.z folder :-

    Filename = install_service.cmd

    mongod.exe --config "c:\wamp\bin\mongo\mongo2.6.6\mongod.cfg" --install --serviceName wampmongodb --serviceDisplayName wampmongodb
    sc config wampmongodb start= demand
    

    The space between start= and demand is required, not a typo

    For completeness also create an uninstall file :-

    Filename = uninstall_service.cmd

    mongod.exe --remove --serviceName wampmongodb
    

    Now create 2 command files to start and stop your mongodb instance

    Filename = start_mongo.cmd

    net start wampmongodb
    

    Filename = stop_mongo.cmd

    net stop wampmongodb
    

    Now start a command window using (Run as Administrator) and use these command files to install and start your MONGODB Server

    CD \wamp\bin\mongo\mongox.y.z
    #Install MONGO as a service
    install_service
    #Start the service
    start_mongo
    

    Now check the c:\wamp\logs folder and make sure there are no errors reported in the mongod.log file

    While still in the command window, check that mongo is running by trying a few simple commands Use the instructions here http://docs.mongodb.org/manual/tutorial/getting-started/ to prove that it is all working.

    NOW ADD THE PHP Extension

    Download from 'http://pecl.php.net/package/mongo'

    Select the version you want and click the Windows icon with the word DLL beside it, in the 'Downloads' column.

    This will take you to the download page for that version of the MONGO PHP extension.

    You should now select the download link that matches the version of the MONGO extension you want, and the matching (x86) for 32bit WAMPServer installs or (x64) for 64bit WAMPServer installs.

    You must click the 'DLL' link otherwise you will get a unix/linux source code.

    Remember you must match the 32 or 64 bit to the version of WAMPServer you downloaded

    So if you are running Windows 64bit but installed WAMPServer 32bit you need the 32bit version of the MONGO extension.

    Also remember that you need the Thread Safe version (TS) to run with WAMPServer's Apache configuration.

    Extract the zip file, and copy php_mongo.dll to your PHP folder eg C:\wamp\bin\php\phpx.y.z\ext

    Edit your php.ini file to add the new extension. To use Mongo with your web server (Apache) use the wampmanager menus to edit php.ini i.e.

    wampmanager -> PHP -> php.ini
    

    and add this line after all the other extension lines

    extension=php_mongo.dll
    

    To use mongo with scripts run from the command line (PHP CLI) edit C:\wamp\bin\php\phpx.y.z\php.ini and add the extension line again in there.

    Start Wampmanager. Or Restart the Apache service. This should refresh WAMPServers config and pick up the new PHP extension, if not do this when wampmanager is running:-

    wampmanager -> Apache -> Service -> Restart Service
    

    Run localhost by :-

    wampmanager -> localhost
    

    and then click on the phpinfo() link on the homepage.

    You should now see a section entitled 'mongo' with some configuration options listed. If you do the PHP MONGO extension is active.

    IMPORTANT

    If you are running Windows Server 2008 R2 or Windows 7 you may have to install this HotFix to resolve an issue with Memory Mapped Files. Request it from here http://support.microsoft.com/kb/2731284/en-us. You have to ask for it, and then they send you an email telling you where it can be downloaded from.

    The link they gave me was http://hotfixv4.microsoft.com/Windows 7/Windows Server2008 R2 SP1/sp2/Fix405791/7600/free/451412_intl_i386_zip.exe

    However I did not need to install it to get to the stage where MONGO was installed and running simple tests from the command line AND through Apache and PHP.

    0 讨论(0)
  • 2020-12-05 22:54

    Updates for PHP 7 version. As per documentation we have to download mongodb-1.2. You can download it from here based on your PHP version.

    0 讨论(0)
  • 2020-12-05 22:56

    first of all you have to download the latest mongo dll files from
    https://s3.amazonaws.com/drivers.mongodb.org/php/index.html
    unzip the downloaded file and you will see a bunch of files like this:
    enter image description here
    now it is time to decide which dll file you have to use.
    open your phpinfo() and search for word compiler. you will see sth like this:
    enter image description here
    so now according to my compiler version (MSVC11) I have to choose file with vc11 word inside their name. according to my PHP version which is 5.5.12 I have to choose file with word 5.5 inside their name.
    now search for word thread safety in your phpinfo
    enter image description here
    and if it was enabled, it means that you have to choose file that doesn't have word nts inside their name but if your thread safety was disabled then you need to choose file with word nts inside their name.
    now according to your installation architecture you may choose files with x86_64 inside their name.
    after choosing the appropriate dll file, rename it to php_mongo.dll and copy paste it to your php extensions directory which is mostly located at C:\wamp\bin\php\php5.5.12\ext
    now open your php.ini file and add this at the end of it.
    extension=php_mongo.dll
    according to
    http://php.net/manual/en/mongo.installation.php
    for installing mongo on windows, you have to also include libsasl.dll in your system PATH.
    libsasl.dll file is mostly located at
    C:\wamp\bin\php\php5.5.12
    add this path to your system PATH.
    reboot your wamp, refresh your phpinfo page and you should see sth like this:
    enter image description here which means that you have installed mongo correctly. :)

    0 讨论(0)
提交回复
热议问题