How can I enable libmongoc ssl in PHP 7 for Mongodb connection?

ぃ、小莉子 提交于 2021-02-07 10:52:57

问题


While connecting to mongodb via PHP7, I am getting following error:

The "SCRAM-SHA-1" authentication mechanism requires libmongoc built with --enable-ssl

This is probably due to libmongoc SSL disabled in php7:

MongoDB support => enabled
MongoDB extension version => 1.4.4
MongoDB extension stability => stable
libbson bundled version => 1.9.4
libmongoc bundled version => 1.9.4
libmongoc SSL => disabled
libmongoc crypto => disabled
libmongoc SASL => disabled
libmongoc compression => enabled
libmongoc compression snappy => disabled
libmongoc compression zlib => enabled

How can I enable it?


回答1:


To resolve this error in PHP7 execute following command as super user:

  1. Install required dependencies:

yum install git php-devel make gcc openssl-devel

  1. Clone, compile and build Mongo PHP Driver from source:

git clone https://github.com/mongodb/mongo-php-driver.git

cd mongo-php-driver/

git submodule update --init

phpize

./configure --with-php-config=/usr/bin/php-config --with-mongodb-ssl=openssl

make

cp ./modules/mongodb.so /usr/lib64/php/modules/

  1. Add mongodb.so to php.ini if not already there.

"extension=mongodb.so"

  1. Restart the webserver to reflect the changes:

systemctl restart httpd.service



来源:https://stackoverflow.com/questions/50763821/how-can-i-enable-libmongoc-ssl-in-php-7-for-mongodb-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!