Reputation: 2819
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."
i have already installed mongoDB driver extension via sudo pecl install mongo
.
locate mongo
shows /usr/lib/php5/20090626+lfs/mongo.so
However, php -v
shows few warnings (which i think is related to 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.
i tried various online tutorial, but nothing helped.
Edit: Here's my 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 -----
Upvotes: 20
Views: 53585
Reputation: 1
After OS update, I had a similar error while running any PHP CLI, simply running "php -v" produced the error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mongodb.so'
I checked the folder, I found the file '/usr/lib/php/20131226/mongodb.so' existed. So, I simply commented on the line "extension=mongo.so" in '/etc/php/5.6/cli/php.ini' file. It fixed my issue.
When checked mongo --version, it was working fine.
Upvotes: 0
Reputation: 602
For me this works well
sudo apt-get install php7.2-mongodb
Change the '7.2' for your php version
Upvotes: 5
Reputation: 5442
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:
sudo pecl uninstall mongodb
sudo pecl install mongodb-1.1.9
composer update
Upvotes: 13
Reputation: 111
My php version is 7.0, but it should work version 5.x too.
If you have this in the file /etc/php/7.0/mods-available/mongo.ini
extension=mongodb.so
Comment that line. After that restart php and it should work.
Upvotes: 9
Reputation: 12240
Add the full path to your mongo.so extension in mongodb.ini
:
extension=/usr/lib/php5/20090626+lfs/mongo.so
Also the [mongo]
should be written exactly like that NOT \[mongo\]
.
Don't forget to reload/restart your web server to load the new configuration.
You can check that everything is ok with:
php -i | grep mongo
Upvotes: 1