PHP 找不到 MongoDB 驱动程序 [英] PHP cannot find MongoDB driver

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

问题描述

在我的 Ubuntu 12.04 安装中,我从 ondej 包安装 PHP5 (5.5).PHP、Apache 和 MySQL 一切正常,我还成功安装了 Mongo daemom 和 Mongo 客户端.但是PHP在pear中找不到MongoDB驱动.

On my Ubuntu 12.04 installation I install PHP5 (5.5) from the ondej package. Everything works ok with the PHP, Apache and MySQL, I also successfully install Mongo daemom and Mongo client. But then PHP cannot locate the MongoDB driver in pear.

我已按照文档中解释的所有步骤操作我已将扩展添加到 CLI 文件夹中的 php.ini 文件重新启动服务器更新了所有内容并再次重新启动服务器.

I have followed all the steps explained in the documentation I have added the extension to the php.ini file in the CLI folder restarted the server updated everything and restart the server again.

我已经被这个问题困扰了很长时间了.我应该在哪里查看.我的 Ubuntu 也在虚拟机上运行,​​我在 VMWare 和 VirtualBox 上都尝试过(据我所知,这与此无关).

I have been stuck on this issue quite long time now. Where should I look in. My Ubuntu is also running on a virtual machine I have tried both on VMWare and VirtualBox (not that this has anything to do as far as I know).

谢谢

附言这里有两个类似的问题,但它们并没有帮助我解决我的问题.

P.S. There are two similar issues here but they did not help me to solve my problem.

推荐答案

我可以从全新的 12.04 安装中提供我的构建配方.Fresh 只是简单地运行配置,为了方便只在最后选择SSH 服务器"选项.

I can give you my build recipe from a fresh 12.04 installation. Fresh being simply running through the configuration and only selecting the "SSH server" option at the end for convenience.

MongoDB 安装是可选的,所以如果你想在不同的服务器上安装,请跳过.但一般说明来自:

MongoDB installation is optional, so if you want this on a different server then skip. But the general instructions come from:

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

所有命令都被拆分而不是自动化,因此您可以看到步骤:

All commands split up and not automated so you can see the steps:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get install software-properties-common
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install mongodb-10gen
sudo apt-get install build-essential
sudo apt-get install php5-dev
sudo apt-get install libcurl4-openssl-dev
sudo pecl install mongo

大量编译器输出.以成功结束并要求修改 php.ini

Lots of compiler output. Ending with success and asking to mofidy php.ini

编辑 CLI 设置.对 apache 配置也做同样的事情

Edit the CLI settings. And do the same for the apache config as well

sudo vi /etc/php5/cli/php.ini
sudo vi /etc/php5/apache2/php.ini

个人喜好,在动态扩展"评论之后

Personal preference, after the comments on 'Dynamic Extensions'

extension=mongo.so

测试使用和连接不会引发错误.创建 test.php:

Test that usage and connection does not throw an error. Create test.php:

<?php

    $m = new MongoClient('mongodb://localhost/',
        array('connectTimeoutMS'=> 500, 'socketTimeoutMS' => 500 ));

?>

并从命令行运行:

php test.php

没有错误.然后你就准备好了.

No errors. Then you are all set up.

$ php -v
PHP 5.5.3-1ubuntu2.1 (cli) (built: Dec 12 2013 04:24:35)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

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

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