Wamp上的MongoDb PHP驱动程序安装问题 [英] MongoDb PHP driver installation issue on wamp

查看:64
本文介绍了Wamp上的MongoDb PHP驱动程序安装问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5.5.12版的php和2.4.9版的wamp以及PHP Extension Build as API20121212,TS,VC11.我正在使用这个dll'php_mongo-1.5.5-5.5-vc11.dll'(重命名为php_mongo),但是当我重新启动我的所有服务mongo db时,仍然没有在phpinfo()上显示.mi哪里出了错? >

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_mongo) but still when i restart my all services mongo db is not displaying on phpinfo().Any pointer where m i going wrong ?

推荐答案

我从没使用过MONGO,但是我很想知道WAMPServer在使用中是否存在问题,因此我进行了快速安装以证明它应该有效,并且确实如此.

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.

首先,您必须下载Mongo数据库管理器本身并进行安装. 从https://www.mongodb.org/downloads

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

2019年8月更新: 立即从此处下载

Updated Aug 2019: Download from here now

因此,您可以自己放置软件,这样我就可以下载ZIP而不是.MSI,这样您就不会让.msi开发人员弄乱您的系统,他们认为应该对您的系统执行什么操作,并且您完全可以控制

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.

下载32位或64位版本以匹配您的操作系统和正在运行的WampServer(32/64)版本.

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

现在,安装"只是从zip中提取文件并将其放置在系统中某个位置的情况.我建议:-

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

将摘录中的bin文件夹复制到c:\wamp\bin\mongo\mongox.y.z(x.y.z以匹配您下载的mongo版本).

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

在该文件夹下创建一个数据文件夹,因此c:\wamp\bin\mongo\mongox.y.z\data 为该文件夹下的第一个数据库创建一个数据文件夹,因此\wamp\bin\mongo\mongox.y.z\data\db

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

c:\wamp\bin\mongo\mongox.y.z\mongod.cfg中为mongo创建一个配置文件,并至少添加以下参数:-

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

现在,如果要让mongodb作为服务运行,请在C:\wamp\bin\mongo\mongox.y.z文件夹中创建一个命令文件,如下所示:-

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 :-

文件名= install_service.cmd

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

start=demand之间的空格是必需的,而不是错字

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

为了完整起见,还创建一个卸载文件:-

For completeness also create an uninstall file :-

文件名= uninstall_service.cmd

Filename = uninstall_service.cmd

mongod.exe --remove --serviceName wampmongodb

现在创建2个命令文件来启动和停止您的mongodb实例

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

文件名= start_mongo.cmd

Filename = start_mongo.cmd

net start wampmongodb

文件名= stop_mongo.cmd

Filename = stop_mongo.cmd

net stop wampmongodb

现在使用(以管理员身份运行)启动命令窗口,并使用这些命令文件来安装和启动MONGODB服务器.

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

现在检查c:\wamp\logs文件夹,并确保mongod.log文件中未报告任何错误

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

仍然在命令窗口中时,通过尝试一些简单的命令来检查mongo是否正在运行 使用此处的说明http://docs.mongodb.org/manual/tutorial/getting-started/来证明一切正常.

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.

现在添加PHP扩展

从" http://pecl.php.net/package/mongo 下载

选择所需的版本,然后在下载"列中单击带有DLL字样的Windows图标.

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

这将带您到该版本的MONGO PHP扩展的下载页面.

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

现在您应该选择与所需的MONGO扩展版本相匹配的下载链接,并为32位WAMPServer安装选择匹配的(x86),对于64位WAMPServer安装选择匹配的(x64).

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.

您必须单击"DLL"链接,否则将获得Unix/Linux源代码.

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

请记住,您必须将32位或64位与您下载的WAMPServer的版本相匹配

因此,如果您正在运行Windows 64位,但是安装了32位WAMPServer,则需要MONGO扩展的32位版本.

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

还请记住,您需要线程安全版本(TS)才能与WAMPServer的Apache配置一起运行.

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

解压缩zip文件,然后将php_mongo.dll复制到您的PHP文件夹中,例如C:\wamp\bin\php\phpx.y.z\ext

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

编辑您的php.ini文件以添加新的扩展名. 要将Mongo与Web服务器(Apache)一起使用,请使用wampmanager菜单编辑php.ini,即

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

要将mongo与从命令行(PHP CLI)运行的脚本一起使用,请编辑C:\wamp\bin\php\phpx.y.z\php.ini并在其中再次添加扩展线.

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.

启动Wampmanager.或重新启动Apache服务. 这应该刷新WAMPServers配置并选择新的PHP扩展,如果在运行wampmanager时不这样做:-

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

通过:-

wampmanager -> localhost

,然后单击主页上的phpinfo()链接.

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

您现在应该看到标题为"mongo"的部分,其中列出了一些配置选项.如果这样做,PHP MONGO扩展将处于活动状态.

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

重要

如果运行的是Windows Server 2008 R2或Windows 7,则可能必须安装此HotFix才能解决内存映射文件问题. 从此处http://support.microsoft.com/kb/2731284/en-us进行请求.您必须提出要求,然后他们会向您发送一封电子邮件,告诉您可以从何处下载它.

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.

他们给我的链接是http://hotfixv4.microsoft.com/Windows 7/Windows Server2008 R2 SP1/sp2/Fix405791/7600/free/451412_intl_i386_zip.exe

但是,我不需要安装它就可以安装MONGO,并可以从命令行以及通过Apache和PHP运行简单的测试.

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.

这篇关于Wamp上的MongoDb PHP驱动程序安装问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆