0

I followed this commands.

$ sudo pecl install mongodb

$ composer require jenssegers/mongodb

 use MongoDB\Client AS Mongo; 
 $mongo = new Mongo();

I am using NGNIX and ubuntu 20. In localhost it is working but in server it is not. In localhost I am using apache2 and in server there ngnix.

Kindly let me know what I am doing wrong. Thanks is advance!

1 Answers1

0

On you're server, first check whether mongodb extension module is loaded by PHP or not

php -i | grep mongo

If there is no output, then check whether mongodb client is installed or not by this command

pecl list mongodb

If no output then installed mongodb client

pecl install mongodb

Once installed, add this line extension=mongodb.so in php.ini file.

Restart nginx webserver and If you're application is using php-fpm restart this service too

Once, everything is at its place, you can re-verify the module is loaded or not using php -i or php -m command

Haridarshan
  • 1,898
  • 1
  • 23
  • 38