Behnam Azimi
Behnam Azimi

Reputation: 2488

Unable to load dynamic library 'mongodb.so' - Debian 8 , PHP 7.2

I have a VPS with Debian 8 OS and a DirectAdmin panel with PHP7.2

To use MongoDB PHP driver, I installed it with the command sudo pecl install mongodb.

After that installation, I added the driver extension to the php.ini file by this command:

echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||" 

But it seems that driver not installed! Because when I exec a PHP command, face this warning:

PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so (/usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so: cannot open shared object file: No such file or directory), /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so.so (/usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Everything is ok in my local (windows), I add the Non Thread Safe (NTS) driver extension to the extensions directory, and It's all!

What I did wrong? Is installation of MongoDB driver on the PHP of DirectAdmin different from installation on a normal PHP?

Update:

MongoDB is not in the result of phpinfo(); too!

Upvotes: 0

Views: 7665

Answers (2)

Behnam Azimi
Behnam Azimi

Reputation: 2488

The issue was about DirectAdmin because it has its own PHP and extensions must add on it.

When I run sudo pecl install mongodb, It looks out default VPS PHP.

This command solved my problem:

cp /usr/lib/php/20170718/mongodb.so /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so

Upvotes: 0

eaglewu
eaglewu

Reputation: 470

Please make sure php extension dir is: /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/

Check:

php -i |grep extension_dir

If not, there are two options to do it:

  1. modify extension_dir in php.ini to /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/
  2. echo "extension=/full_path_through_pecl_installed/mongodb.so" > php.ini

Upvotes: 1

Related Questions