致命错误 - 找不到“Mongo"类 [英] Fatal Error - 'Mongo' class not found
问题描述
我正在尝试执行此操作:
I'm trying to execute this:
<?php
// connect
$m = new Mongo();
?>
但我收到以下错误:
致命错误:在 C:\wamp\www 中找不到Mongo"类......
Fatal error: Class 'Mongo' not found in C:\wamp\www.....
信息:
- PHP:5.38
- MongoDB:mongodb-win32-i386-2.0.2
- MongoDB PHP 驱动程序:mongo-1.1.4-php5.3vc6ts
- WampServer:2.2
- 操作系统:Windows 7 Enterprise SP1
我已经很好地遵循了 MongoDB 安装(包括将 DLL 添加到 ext & php.ini),我已经启动了 mongod.exe 并且 WAMP 正在运行.
I've followed the MongoDB installation fine (incl. adding the DLL to ext & php.ini), I've started mongod.exe and WAMP is running.
我让它在另一台 Windows 7 机器上运行(Windows 7 Professional).这让我很好奇.所以现在我的 Windows 7 Enterprise SP1 机器具有相同的 http.conf
、php.ini
、C:\wamp\bin\mongodb
内容(因此数据库完全相同)和完全相同的批处理文件来启动 mongod.exe
作为我的 Win7 Professional 机器.
I have got it running on another Windows 7 machine (Windows 7 Profressional). That got me curious. So now my Windows 7 Enterprise SP1 machine has the same http.conf
, php.ini
, C:\wamp\bin\mongodb
contents (therefore DBs are the exact same) and the exact same batch file to start mongod.exe
as my Win7 Professional machine.
但是,我在 Win7 Enterprise SP1 机器上所能做的就是通过命令行连接.我的 Win7 Professional 机器的 phpinfo()
包含:
我的 Win7 Enterprise SP1 机器不包含对 MongoDB 的任何引用.
But still, all I can do on my Win7 Enterprise SP1 machine is connect via command line. My Win7 Professional machine's phpinfo()
contains:
My Win7 Enterprise SP1 machine doesn't contain any reference to MongoDB.
我用来启动MongoDB的批处理文件的内容:
The contents of the batch file I use to start MongoDB:
"C:\wamp\bin\mongodb\bin\mongod.exe" --logpath "C:\wamp\bin\mongodb\logs\error.log" --logappend --dbpath "C:\wamp\bin\mongodb\data\db" --directoryperdb --service
Net Start "MongoDB"
pause
推荐答案
问题在于 PHP 驱动程序 (php_mongo.dll
).出于某种原因,Apache/WAMP 只是不喜欢 mongo-1.1.4-php5.3vc6ts
版本.我的 Windows 7 Professional 机器有 mongo-1.2.5-php5.3vc9ts
版本.这是两台机器之间的唯一区别.
The problem was the PHP driver (php_mongo.dll
). Apache/WAMP just did not like the mongo-1.1.4-php5.3vc6ts
version for some reason. My Windows 7 Professional machine had the mongo-1.2.5-php5.3vc9ts
version. That was the only difference between the two machines.
我最初一直在 Windows 7 Enterprise 机器上使用 mongo-1.2.5-php5.3vc9ts
版本的驱动程序,但更改为 mongo-1.1.4-php5.3vc6ts
版本,当我解决问题时.因此,最初的问题实际上可能只是数据库路径 data\db
不存在/无法找到(并且需要使用 --dbpath
指定)运行/启动 mongod.exe
时).
I originally had been using the mongo-1.2.5-php5.3vc9ts
version of the driver on the Windows 7 Enterprise machine but changed to the mongo-1.1.4-php5.3vc6ts
version when I was troubleshooting the problem. So the original problem could actually just have been that the database path data\db
didn't exist/couldn't be found (and needed to be specified using --dbpath
when running/starting mongod.exe
).
这篇关于致命错误 - 找不到“Mongo"类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!