Record the pit of PHP7-MONGODB expansion once

Source: Internet
Author: User
Tags install php mongodb openssl phpinfo

CentOS Install PHP 7 's MongoDB extension encounters the Pit

When I deploy a PHP environment on Docker, the installation of MongoDB extensions encounters a pit:
PHP Fatal error:uncaught mongodb\driver\exception\authenticationexception:the "scram-sha-1" authentication mechanism Requires LIBMONGOC built With–enable-ssl
This error should only appear on MongoDB that is set up to require login verification.

I didn't think much at first, after I found the extension of MongoDB on pecl, I compiled it directly:

phpize./configuremakemake install

After simply writing the test code, the following error occurred:
PHP Fatal error:uncaught mongodb\driver\exception\authenticationexception:the "scram-sha-1" authentication mechanism Requires LIBMONGOC built With–enable-ssl in/var/www/html/mongo.php:8\nstack trace:\n#0/var/www/html/mongo.php (8): Mongodb\driver\manager->executebulkwrite (' Test.tb ', Object (mongodb\driver\bulkwrite)) \n#1 {main}\n thrown in/ Var/www/html/mongo.php on line 8

At first the suspicion is that ./configure you need to add some option parameters, to ./configure --help find the relevant similar to the above error in the above --enable-ssl options, Target Lock:

However, even after this option is added: It ./configure --with-mongodb-ssl is still useless to recompile.

Baidu a circle can not find a solution, on Google a bit, sure enough to find the key to the problem:

The problem is on the disabled in the red box on the phpinfo's MongoDB extension information.

The basic reason is that I used the Docker image is too clean, even OpenSSL did not, so first installed on OpenSSL:

yum install -y openssl openssl-devel
    • 1

Recompile the MongoDB extension ( ./configure No need to add the above option parameter, because the default value is --with-mongodb-ssl=auto ), and then go to Phpinfo to see:

Really different, and then run the test code, test success!

Record the pit of PHP7-MONGODB expansion once

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.