PHP 无法加载动态库 (mongo.so)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24030255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP unable to load dynamic library (mongo.so)
提问by Kanav
i'm trying to use rockmongo. After installation, i'm unable to use it. It says "To make things right, you must install php_mongo module. Here for installation documents on PHP.net."
我正在尝试使用rockmongo。安装后,我无法使用它。它说“为了使事情正确,你必须安装 php_mongo 模块。这里是 PHP.net 上的安装文档。”
i have already installed mongoDB driver extension via sudo pecl install mongo
.
我已经通过sudo pecl install mongo
.
locate mongo
shows /usr/lib/php5/20090626+lfs/mongo.so
locate mongo
显示 /usr/lib/php5/20090626+lfs/mongo.so
However, php -v
shows few warnings (which i think is related to mongo)
但是,php -v
显示很少的警告(我认为这与 mongo 相关)
PHP: syntax error, unexpected $end, expecting ']' in /etc/php5/cli/conf.d/mongodb.ini on line 3
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/mongo.so' - /usr/lib/php5/20100525+lfs/mongo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.4.28-1+deb.sury.org~precise+1 (cli) (built: May 5 2014 09:39:26)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
i opened /usr/lib/php5/
and found out that there are another directory(20090626+lfs) which contains mongo.so.
我打开/usr/lib/php5/
并发现还有另一个目录(20090626+lfs)其中包含 mongo.so。
i tried various online tutorial, but nothing helped.
我尝试了各种在线教程,但没有任何帮助。
Edit: Here's my mongodb.ini
编辑:这是我的 mongodb.ini
;----- start -----
extension=mongo.so
\[mongo\]
; If the driver should reconnect to mongo
mongo.auto_reconnect = true
; Whether to allow persistent connections
mongo.allow_persistent = On
; Maximum number of persistent connections (-1 means unlimited)
mongo.max_persistent = -1
; Maximum number of links (persistent and non-persistent, -1 means unlimited)
mongo.max_connections = -1
; Default host for mongo connection
mongo.default_host = www.example.com
; Default port for mongo database
mongo.default_port = 42
; When saving files to the database, size of chunks to split them into
mongo.chunk_size = 1024
; Specify an alternate character to $ to use for special db functions ($set, $push, $exists, etc.)
mongo.cmd = "$"
;----- end -----
采纳答案by J.C. Gras
I solved this problem using the 1.1.9 version of mongodb driver for php 5. First uninstall the current version of mongodb and then install the 1.1.9 version:
我使用php 5的 mongodb 驱动程序的 1.1.9 版本解决了这个问题。先卸载当前版本的mongodb,再安装1.1.9版本:
sudo pecl uninstall mongodb
sudo pecl install mongodb-1.1.9
composer update
回答by David Ginosyan
My php version is 7.0, but it should work version 5.x too.
我的 php 版本是 7.0,但它也应该适用于 5.x 版本。
If you have this in the file /etc/php/7.0/mods-available/mongo.ini
如果你在文件中有这个 /etc/php/7.0/mods-available/mongo.ini
extension=mongodb.so
Comment that line. After that restart php and it should work.
注释该行。之后重新启动php,它应该可以工作。
回答by Christian P
Add the full path to your mongo.so extension in mongodb.ini
:
在 mongo.so 扩展中添加完整路径mongodb.ini
:
extension=/usr/lib/php5/20090626+lfs/mongo.so
Also the [mongo]
should be written exactly like that NOT \[mongo\]
.
也[mongo]
应该完全像那个 NOT 那样写\[mongo\]
。
Don't forget to reload/restart your web server to load the new configuration.
不要忘记重新加载/重新启动您的 Web 服务器以加载新配置。
You can check that everything is ok with:
您可以通过以下方式检查一切是否正常:
php -i | grep mongo