doutao8774 2016-06-05 11:48
浏览 66
已采纳

Windows Wamp:Mongodb Extension无法启动

I have install mongo db in my windows 10 PC using MSI download. My mongo db files are stored in

C:\Program Files\MongoDB

My database is located in:

C:\data\db

I have tested that mongo db is running and the environment variable is set.

My php version informatin is:

PHP Version 5.4.12
Zend Extension Build    API220100525,TS,VC9

I have downloaded my mongo driver from :

https://s3.amazonaws.com/drivers.mongodb.org/php/index.html

I am using :

php_mongo-1.5.4.zip 
php_mongo-1.5.4-5.4-vc9-x86_64.dll

I have renamed and loaded mongo extension in php.ini

extension=php_mongo.dll

I tried different version of the drivers are they were giving me compatibility issues but only php_mongo-1.5.4-5.4-vc9-x86_64.dll worked without giving me an error or warning at wamp startup.

HOWEVER, when I look inside the checked extensions of php and mongo is not checked and even when I click to check it, wamp restart but its still not checked. Why isn't mongo db extension loading up in wamp?

I have checked php_error.log and there is nothing there.

  • 写回答

1条回答 默认 最新

  • duanlu7680 2016-06-05 11:58
    关注

    This is the process I used to get MONGO working

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

    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 whatever the .msi devleoper thinks 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 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
    

    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 MONGO. 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.

    Extract the zip file, and copy php_mongo.dll to your PHP folder eg '\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 '\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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度