Assistance Needed with MongoDB Extension Installation for PHP 8.3

Hello,

I recently updated my system from PHP 8.2 to PHP 8.3. The update process was straightforward through your interface. However, I encountered an issue with the MongoDB extension, which I need for my projects.

While using PHP 8.2, I successfully installed the MongoDB extension with a simple script. But, when I attempt to replicate the process for PHP 8.3, I consistently face errors, and the installation fails.

Could you provide guidance or assistance on how to properly install and configure the MongoDB extension for PHP 8.3 on Cleavr? Any help or suggestions would be greatly appreciated.

Thank you in advance for your support.

PHP 8.2.13


#!/bin/bash
# This script installs the MongoDB extension for PHP 8.2.13 on Ubuntu

# Set DEBIAN_FRONTEND to noninteractive to avoid interactive dialog
export DEBIAN_FRONTEND=noninteractive

# Update package lists
sudo apt-get update -y

# Install PHP development tools and the PEAR extension manager
sudo apt-get install -y php-pear php-dev

# Install the MongoDB PHP extension
sudo pecl install mongodb

# Add the extension to your PHP configuration
echo "extension=mongodb.so" | sudo tee -a /etc/php/8.2/fpm/php.ini
echo "extension=mongodb.so" | sudo tee -a /etc/php/8.2/cli/php.ini

# Restart PHP-FPM to apply changes
sudo systemctl restart php8.2-fpm

# Unset DEBIAN_FRONTEND variable
unset DEBIAN_FRONTEND

Hello @webify,

Could you also let us know the error messages you encountered?

Hello @webify,

We’ll look into the matter and get back to you.

1 Like

Hello @webify,

Did you encounter any issues with extension installation? Can you please verify that the MongoDB extension has been installed successfully?

Lets also confirm that the mongodb.so file exists in the directory specified in the error message. In your case, it’s looking for the file in /usr/lib/php/20230831/.

Hello @webify, this may be a better topic to ask in a mongodb community since it seems pretty specific to mongo.

The only thing I can think of is in the script you posted in the first comment, to ensure all of the 8.2’s are swapped out for 8.3.

Hello Chris,

Could you please execute the command apt install php8.3-mongodb and check if it resolves the issue? It seems that the MongoDB extension for PHP 8.2 is being installed by default, and we want to ensure it’s installed for PHP 8.3 instead.

This command should install the MongoDB extension specifically for PHP 8.3, helping to address the problem you’re facing. Let me know if this resolves the issue for you.