关闭
dongyi3616 2016-06-08 07:18
浏览 162
已采纳

使用MacPorts在Mac OS X 10.11上安装MongoDB

I am trying to install MongoDB on my computer running Mac OS X 10.11 (El Capitan).

My Apache + PHP configuration was already working correctly.

I installed MongoDB and PHP drivers for MongoDB through MacPorts:

sudo port install mongodb
sudo port install php55-mongodb

Installation ran correctly.

I added mongodb.so file to the extensions loaded in the php.ini file:

extension=/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/mongodb.so

When I run phpinfo() function in php file, mongodb extension seems to be loaded correctly: enter image description here

I tried to test my connexion by initializing a MongoClient instance:

<?php

    $mongoDB = new MongoClient();

    var_dump($mongoDB);

?>

Unfortunately, I got a HTTP ERROR 500, and I got the following line in my Apache logs:

PHP Fatal error:  Class 'MongoClient' not found in ...

Did I make something wrong ?

  • 写回答

2条回答 默认 最新

  • dongtun3328 2016-06-09 09:48
    关注

    Finally found a solution to my problem.

    As @neverpanic and @Zagonine made me understand, php-mongodb and php-mongo are not the same extension.

    If you want to use old PHP driving classes, you should use php-mongo package instead of the very new php-mongodb.

    Trying to install latest php-mongo extension, I had an other problem related to OpenSSL. To bypass it, I installed an old version of php-mongo extension:

    sudo /usr/local/pear/bin/pecl install mongo-1.5.8
    

    Hopefully it will help someone else.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部