gpt4 book ai didi

PHP 7 : MongoDB Driver issue

转载 作者:可可西里 更新时间:2023-11-01 09:57:00 28 4
gpt4 key购买 nike

我在尝试安装 MongoDB PHP 库时遇到错误:

$ 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

当我执行 phpinfo() 时,我可以看到以下内容:

mongodb

mongodb support enabled
mongodb version 1.2.1
mongodb stability stable
libmongoc version 1.5.0
libbson version 1.5.0

当我执行 locate mongodb.so 时,这里是我的 mongodb.so 文件所在的位置:

/usr/lib/php/20151012/mongodb.so

我注意到,这是 20-mongodb.ini 文件所在的路径:

/etc/php/7.0/apache2/conf.d

此外,sudo pecl mongodb install 返回以下内容:

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 返回:

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 <bjori@php.net> (lead)
Jeremy Mikola <jmikola@php.net> (lead)
Derick Rethans <derick@php.net> (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

我在 Google 上搜索了几个小时,但还是一无所获。谢谢。

最佳答案

是的,有很好的答案。这是我在 php7.1 中安装 mongo 所做的。我使用的是 ubuntu16.04 64 位:

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

这一切都是为了 nginx。如果您使用的是 apache,请添加:

echo 'extension=mongodb.so' | sudo tee /etc/php/7.1/apache2/conf.d/30-mongodb.ini

还有一个。如果您在使用 mongo 时继续出现错误。类似的东西:

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

不要绝望,运行以下命令:

sudo pecl uninstall mongodb
sudo pecl install mongodb

关于PHP 7 : MongoDB Driver issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41051446/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com