doubi9531 2017-01-06 05:43
浏览 106
已采纳

MongoDB PHP驱动程序无法在Linux AWS上运行

I'm trying to install the MongoDB PHP driver so I can connect to a MongoDB Server on another machine. Using PHP 5.6 on AWS Linux.

I used sudo pecl install mongodb. Initially there were several errors regarding dependencies but I added them all and it then seems to have installed without any errors.

However, when loading phpinfo() I don't see any reference to Mongo. When I try to run:

$connection = new MongoClient(); I get

PHP Fatal error:  Class 'MongoClient' not found in /var/www/html/mongo.php on line 3

I did put in extension=mongodb.so into my php.ini but that results in another error:

PHP Startup: Unable to load dynamic library '/usr/lib64/php/5.6/modules/mongodb.so' - /usr/lib64/php/5.6/modules/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0

It seems this error has to do with the order in which json loads relative to MongoDB. But as in my case it doesn't appear MongoDB is loading at all I'm not sure if that applies here.

I'd appreciate assistance as to why this isn't working.

  • 写回答

3条回答 默认 最新

  • dongtanxi5676756 2017-01-06 06:04
    关注

    I had faced the same situation and i got this solution from mongo developers You don't need to put mongodb.so in php.ini instead make it a separate module If you are using debian

    cat << EOF > /etc/php5/mods-available/mongodb.ini
    ; priority=99
    extension=mongodb.so
    EOF
    php5enmod mongodb
    

    if you are using fedora

    echo "extension=mongodb.so" > /etc/php.d/50-mongodb.ini
    

    Then restart your apache And it will work fine.

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

报告相同问题?

悬赏问题

  • ¥15 CCF-CSP 2023 第三题 解压缩(50%)
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
  • ¥100 matlab2009 32位一直初始化
  • ¥15 Expected type 'str | PathLike[str]…… bytes' instead
  • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数