mongo-php-driver icon indicating copy to clipboard operation
mongo-php-driver copied to clipboard

PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so'

Open thangbv opened this issue 1 year ago • 3 comments

I installed on Centos 7 with PHP 7.4. MongoDB server is 7.0.4. But when starting nginx, I receive a warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib64/php/modules/mongodb.so (/usr/lib64/php/modules/mongodb.so: undefined symbol: BIO_meth_set_read), /usr /lib64/php/modules/mongodb.so.so (/usr/lib64/php/modules/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0. Also in php.ini don't see mongodb extension

thangbv avatar Dec 28 '23 06:12 thangbv

How did you install the mongodb php extension? Do you have the same PHP version running on the cli and php-fpm? Did you restart php-fpm after installing the mongodb extension?

GromNaN avatar Jan 04 '24 17:01 GromNaN

@GromNaN same question

php8.2 ,ubuntu 22 :

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20210902/mongodb.so' (tried: /usr/lib/php/20210902/mongodb.so (/usr/lib/php/20210902/mongodb.so: undefined symbol: executor_globals), /home/vscode/software/php/lib/php/extensions/no-debug-zts-20220829//usr/lib/php/20210902/mongodb.so.so (/home/vscode/software/php/lib/php/extensions/no-debug-zts-20220829//usr/lib/php/20210902/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

install php

#!/bin/bash
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y autoconf libpng-dev libjpeg-dev git libsystemd-dev build-essential g++ libcurl4-openssl-dev libssl-dev gcc wget pkg-config curl  libxml2 libxml2-dev libzip-dev libonig-dev librust-onig-dev sqlite3 libsqlite3-dev


PREFIX_DIR=$HOME/software/php
./configure --prefix=$PREFIX_DIR --with-fpm-systemd --enable-fpm  --with-curl --enable-mysqlnd --with-zip --with-config-file-path=${PREFIX_DIR}/config --with-config-file-scan-dir=${PREFIX_DIR}/config  --enable-sockets  --with-pdo-mysql  --enable-pcntl   --enable-mbstring  --enable-intl --enable-zts --with-zlib --enable-bcmath --enable-bcmath --with-openssl --enable-gd --with-jpeg; 
make -j4 && make install
echo export PATH=$HOME/software/php/bin:$PATH>>~/.bashrc;
source ~/.bashrc;

install mongodb

sudo pecl install mongodb

Do you have the same PHP version running on the cli and php-fpm?

no

Did you restart php-fpm after installing the mongodb extension?

yes, still not work

cloud-chang avatar Jan 08 '24 21:01 cloud-chang

According to this issue, PHP doesn't follow SemVer, nor has backwards-compatible ABI in minor versions. So, pay attention to the PHP and MongoDB driver versions. The driver has to be built for the same minor version of PHP.

mitkonikov avatar Mar 24 '25 14:03 mitkonikov