I just got errors when I try to install MongoDB PHP Library:
$ composer require "mongodb/mongodb=^1.0.0"
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
When I execute phpinfo() I can see the following:
mongodb
mongodb support enabled
mongodb version 1.2.1
mongodb stability stable
libmongoc version 1.5.0
libbson version 1.5.0
When I execute locate mongodb.so here's where my mongodb.so file is:
/usr/lib/php/20151012/mongodb.so
As I can notice, this is the path where 20-mongodb.ini file is:
/etc/php/7.0/apache2/conf.d
Also, sudo pecl mongodb install returns the following:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongodb.so' - /usr/lib/php/20151012/mongodb.so: undefined symbol: php_json_serializable_ce in Unknown on line 0
sudo pecl info mongodb returns:
About pecl.php.net/mongodb-1.2.1
================================
Release Type PECL-style PHP extension (source code)
Name mongodb
Channel pecl.php.net
Summary MongoDB driver for PHP
Description The purpose of this driver is to provide
exceptionally thin glue between MongoDB
and PHP, implementing only fundemental and
performance-critical components
necessary to build a fully-functional MongoDB
driver.
Maintainers Hannes Magnusson <[email protected]> (lead)
Jeremy Mikola <[email protected]> (lead)
Derick Rethans <[email protected]> (lead)
Release Date 2016-12-07 18:25:03
Release Version 1.2.1 (stable)
API Version 1.2.1 (stable)
License Apache License
(http://www.apache.org/licenses/LICENSE-2.0)
Release Notes ** Bug
* [PHPC-848] - Fix BSON encoding of
immutable arrays and documents with circular
references
Required Dependencies PHP version 5.4.0-7.99.99
PEAR installer version 1.4.8 or newer
package.xml version 2.0
Last Modified 2016-12-09 00:28
Previous Installed 1.2.0
Version
I searched on Google for a few hours, but still nothing. Thank you.
Yes, there are good answers. Here's what I did to install mongo in php7.1. I am using ubuntu16.04 64bit:
sudo aptitude install -y php7.1-dev pkg-config
sudo -H pecl channel-update pecl.php.net
sudo aptitude install -y libcurl4-openssl-dev pkg-config libssl-dev libsslcommon2-dev
sudo pecl install mongodb
echo 'extension=mongodb.so' | sudo tee /etc/php/7.1/fpm/conf.d/30-mongodb.ini
echo 'extension=mongodb.so' | sudo tee /etc/php/7.1/cli/conf.d/30-mongodb.ini
sudo systemctl restart php7.1-fpm.service
It it all for nginx. If you are using apache, please add:
echo 'extension=mongodb.so' | sudo tee /etc/php/7.1/apache2/conf.d/30-mongodb.ini
And one more. If you continue to have an error when working with mongo. Something like that:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/mongodb.so' - libssl.so.1.0.2: cannot open shared object file: No such file or directory in Unknown on line 0
Do not despair, run the following commands:
sudo pecl uninstall mongodb
sudo pecl install mongodb
First type this command /usr/bin/php-config to see where the extension directory is.
You will see something like this --extension-dir [/usr/lib/php/20131226]
Than ls in that folder see if the mongo.so is there , if not put it there.
Type whereis php to locate the php you are using in CLI
Edit the php.ini for the CLI and add the extension=mongo.so
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With