Problem installing PHP driver for MongoDb on wamp

I have php 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_mongo), but still when I restart all my services, the mongo db does not show up on phpinfo (). Any pointer where mi is wrong?

+5


source to share


5 answers


I've never used MONGO, but I was curious to see if there were any problems using it with the WAMPServer, so I did a quick install to prove it works and it works .

Here is a list of what I have done, hopefully this will help you understand what you may have done wrong.

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

Updated Aug 2019: Download from here now

So you can host the software yourself, I would download the ZIP and NOT the .MSI in such a way that the .msi developer does not mess up your system and what they think should be done to your system and you are in complete control ...

Download the 32-bit or 64-bit version that matches your OS version and WampServer (32/64).

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

Copy the folder bin

from the extraction to c:\wamp\bin\mongo\mongox.y.z

(xyz to match the mongo version you downloaded).

Create a data folder in that folder, so c:\wamp\bin\mongo\mongox.y.z\data

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

Create config file for mongo in c:\wamp\bin\mongo\mongox.y.z\mongod.cfg

and add at least these parameters: -

NOTE: these are just parameters that will run it, NOT a DEFINITIVE PARAMETER!

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 mongodb to run as a service, create a batch file, for example in the folder C:\wamp\bin\mongo\mongox.y.z

: -

File name = 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

      

Requires a space between start=

and demand

, not a typo

For completeness, also create a delete file: -

File name = uninstall_service.cmd

mongod.exe --remove --serviceName wampmongodb

      

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

File name = start_mongo.cmd

net start wampmongodb

      

Filename = stop_mongo.cmd

net stop wampmongodb

      

Now start a command window with (Run as administrator) and use these command files to install and run MONGODB server

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

      

Now check the folder c:\wamp\logs

and make sure there are no error messages in the mongod.log file.



From the command window, check that mongo is working with a few simple commands. Use the instructions here http://docs.mongodb.org/manual/tutorial/getting-started/

to prove everything works.

NOW ADD PHP Extension

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

Select the version you want and click the Windows icon with the word DLL next to it in the Downloads column.

You will be taken to the download page for this version of the MONGO PHP extension.

Now you need to select the download link corresponding to the version of the MONGO extension you need and corresponding (x86) for a 32-bit WAMPServer installation or (x64) for a 64-bit WAMPServer installation.

You must click on the "DLL" link, otherwise you will get the Unix / Linux source code.

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

Therefore, if you are using Windows 64bit, but have installed WAMPServer 32bit, you need the 32-bit version of the MONGO extension.

Also remember that you need a Thread Safe (TS) version to work with the Apache WAMPServer configuration.

Extract the zip file and copy php_mongo.dll

to your PHP folder likeC:\wamp\bin\php\phpx.y.z\ext

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

wampmanager -> PHP -> php.ini

      

and add this line after all other internal 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 re-add the extension line there.

Start Wampmanager. Or restart the Apache service. This should update the WAMPServers config and select the new PHP extension, if not when wampmanager is running: -

wampmanager -> Apache -> Service -> Restart Service

      

Run localhost: -

wampmanager -> localhost

      

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

You should now see a section entitled "Mongo" that lists some of the configuration options. If you do, PHP MONGO extension is active.

IMPORTANT

If you are using Windows Server 2008 R2 or Windows 7, you may need to install this hotfix to resolve the memory-mapped file issue. Request it here http://support.microsoft.com/kb/2731284/en-us

. You have to ask for it and then they will send you an email telling you where to download it 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 didn't need to install it to get to the step where MONGO was installed and simple tests were run from the command line AND via Apache and PHP.

+14


source


first of all you need 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's time to decide which file dll you should be using.
open your phpinfo () and look for the word compiler . you will see sth like this:
enter image description here
so now, according to my version of the compiler (MSVC11), I have to select a file named vc11 inside my name. according to my PHP version which is 5.5.12. I need to select a file with the word 5.5 inside their name.
now look for the word thread safety in your phpinfo
enter image description here
and if it was enabled, that means you need to select the file that does not have the word nts , but if your thread safety is disabled, you need to select the file with the word nts inside their name.
now according to your installation architecture you can select files with x86_64 inside your name.
after selecting the appropriate dll file, rename it to php_mongo.dll and copy it to your php extensions directory which is mostly located at C: \ wamp \ bin \ php \ php5.5.12 \ ext
now open the php.ini file and add it to the end. extension = php_mongo.dll
according to http://php.net/manual/en/mongo.installation.php
to install mongo on windows you must also include libsasl.dll in your system PATH.
The libsasl.dll file is mainly at
C: \ WAMP \ Bin \ PHP \ php5.5.12
 add this path to your system PATH.
reload your wamp, refresh your phpinfo page and you will see the following, enter image description here which means you have installed mongo correctly. :)



+17


source


If you are still facing the problem, follow these two rules:

  • Make sure you download the drivers from http://pecl.php.net/package/mongo
  • Try drivers version 1.5.1 (when I write this, the latest driver is 1.6.8, but 1.6.8 to 1.5.5 nothing works for me)
+1


source


Did you put the .dll in your php.ini file (correct)?

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

Scott

0


source


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

0


source







All Articles