PHP致命错误:类'MongoClient'未找到 [英] PHP Fatal Error: Class 'MongoClient' not found

查看:3877
本文介绍了PHP致命错误:类'MongoClient'未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache,这只是下code网站:

I have a site using Apache that is just the following code:

<?php $m = new MongoClient(); ?>

当我尝试访问它,我得到error.log中的误差

and when I try to access it, I get the error in error.log

`PHP Fatal Error: Class 'MongoClient' not found`

以下是这可能是错误的设置,但我不认为是。

The following are settings which might be wrong, but I don't think are.

PHP -i | grep的配置 => 配置文件(php.ini中)路径=&GT;在/ etc / PHP5 / CLI |加载配置文件= GT; /etc/php5/cli/php.ini

的grep'蒙戈'/etc/php5/cli/php.ini => 扩展= mongo.so

PHP -i | grep的扩展 =>
的extension_dir =&GT; / usr / lib目录/ PHP5 / 20121212 =&GT; / usr / lib目录/ PHP5 / 20121212

LS / usr / lib目录/ PHP5 / 20121212 / | grep的mongo.so => mongo.so

我一直没能找到任何建议我安装错了,或者对其进行配置错误。我使用安装了它在过去的两小时内 PECL sudo的梨安装-f PECL /蒙戈 sudo的PECL安装蒙戈

I haven't been able to find anything to suggest I installed it wrong or have it wrongly configured. I installed it within the past two hours using pecl and pear (sudo pear install -f pecl/mongo and sudo pecl install mongo)

我已经重新启动我的Apache,甚至我的电脑多次。

I've restarted my Apache and even my computer multiple times.

那么,为什么我收到错误类MongoClient'未找到

So why am I getting the error Class 'MongoClient' not found?

我在Ubuntu。 PHP版本5.5。

I'm on Ubuntu. PHP version 5.5.

编辑:我刚刚发现MongoClient是有效的,当我以交互方式运行PHP。也许它有与用户的权限/用户安装问题怎么办?

I've just discovered that MongoClient is valid when I run php in interactive mode. Perhaps it has to do with a user permission/user installation issue?

推荐答案

的问题是,我是用 PHP -i | grep的配置找到.ini文件。这导致 /etc/php5/cli/php.ini 。现在回想起来,这应该是一个明显的赠品: CLI 表示命令行界面,基本上是跨preTER。我需要的是Apache的是使用INI文件。

The problem was that I was using php -i | grep 'Configuration' to find the .ini file. This lead to /etc/php5/cli/php.ini. In retrospect, this should have been an obvious giveaway: cli means command line interface, basically for the interpreter. What I needed was the ini file that Apache was using.

不幸的是,要做到这一点,因为我无法登录到没有好方法 www数据用户,但我做了有$ C $文件ç

Unfortunately, there was no great way to do this as I couldn't log into the www-data user, but I made a file that had the code

<?php
  phpinfo();
?>

和透露,.ini文件的位置实际上是 /etc/php5/apache2/php.ini

在我更新的的有扩展= mongo.so ini文件,该模块被加载在启动,所以我重新启动,一切工作现在。

Once I updated that ini file with extension=mongo.so, the module was loaded at startup, so I restarted and everything is working now.

这篇关于PHP致命错误:类'MongoClient'未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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