(Note: I'm running Ubuntu server 22.04 with PHP 8.1)
I have followed what I assume to be the standard procedure for setting up PHP with MongoDB on Ubuntu systems, that being:
- install
php-fpm - install
php-pear,php-devandphp-mongodb pecl install mongodb- add
extension=mongodb.soto/etc/php/8.1/fpm/php.ini - reload and restart
php8.1-fpm - install composer &
composer require mongodb/mongodbin project root
However, when I run any kind of PHP code that makes use of the MongoDB driver (required with require_once __DIR__ . "/vendor/autoload.php";); I get the following error: php: symbol lookup error: /usr/lib/php/20210902/mongodb.so: undefined symbol: ns_initparse.
I have not found anybody else with a similar issue, am I missing some new required step, or should I just drop back down to Ubuntu 20.04 with PHP 7.4 (which works on my development machine running Linux Mint 20.3). Thank you in advance.
I also face this problem, I sovle it following below step
Make sure you has been install php mongodb
To do this in Ubuntu, you'll need the php-pear plugin and php-dev
then you can run:
then add "extension=mongodb.so" to php.ini
then restart your php service
or
Hope can help you!!!
ref : https://www.php.net/manual/en/mongodb.installation.pecl.php#125027