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?

This was my first attempt:


usage: sudo -h | -K | -k | -V
usage: sudo -v [-ABknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-ABknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
            [command]
usage: sudo [-ABbEHknPS] [-r role] [-t type] [-C num] [-D directory] [-g group]
            [-h host] [-p prompt] [-R directory] [-T timeout] [-u user]
            [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-ABknS] [-r role] [-t type] [-C num] [-D directory] [-g group]
            [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] file ...

this was my second attempt:

usage: sudo -h | -K | -k | -V usage: sudo -v [-ABknS] [-g group] [-h host] [-p prompt] [-u user] usage: sudo -l [-ABknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command] usage: sudo [-ABbEHknPS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>] usage: sudo -e [-ABknS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] file ... PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20230831/mongodb.so (/usr/lib/php/20230831/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/mongodb.so.so (/usr/lib/php/20230831/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20230831/mongodb.so (/usr/lib/php/20230831/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/mongodb.so.so (/usr/lib/php/20230831/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20230831/mongodb.so (/usr/lib/php/20230831/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/mongodb.so.so (/usr/lib/php/20230831/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20230831/mongodb.so (/usr/lib/php/20230831/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/mongodb.so.so (/usr/lib/php/20230831/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

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/.

No idea, sorry.
Unfortunately i have no knowledge of this.
Last time i did the script ( that i posted ) with ChatGPT and it worked.

This time i tried 4 different scripts and none of them worked.

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.

Hi again,

I believe my previous message might not have conveyed my request effectively.

I’m looking to install the MongoDB extension ( mongo.so ) for PHP on the server. Notably, your service already supports various PHP extensions like SQLite, Iconv, Mysql PDO, etc., but it seems the MongoDB extension is not included.

Considering your commitment to simplifying server management - a promise encapsulated in your motto, “Server management made easy” - I was hoping this extension installation could be seamlessly integrated. Your service excellently alleviates server and deployment management challenges, enabling users to concentrate on creating impactful websites and applications.

The official MongoDB website, being the primary source for this extension, is the go-to resource for its integration, as they are the authors of MongoDB and its related extensions.

This request falls squarely within the realm of server management. If this is outside your service scope or not a priority, that’s completely understandable. I will find a solution and/or way to install it. However, I do feel this task aligns more with your expertise than mine.

I appreciate your understanding and look forward to a possible solution. There are no hard feelings; I just wanted to clarify that my query is more about server infrastructure than coding or extension functionality.

I’m a happy customer and have only good things to say about cleavr so please don’t understand my perspective or the repeated request the wrong way!

Have a nice weekend and best regards
/chris

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.

I gave it a try, but as I mentioned earlier, server management isn’t my forte; I’m more at home with web development. I attempted another quick script and encountered the following error:

“WARNING: apt does not have a stable CLI interface. Use with caution in scripts. E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?”

Honestly, it baffles me that in 2024, we don’t have a more straightforward, button-and-checkbox solution for this, or why it’s not a pre-installed feature. It seems to me that this sort of task should be exactly what falls under your motto, “Server management made easy.” Cleavr is supposed to alleviate the headaches of server and deployment management, allowing us to focus on creating impactful websites and apps.

Ideally, there should be an intuitive button or checkbox in your backend interface for simple activation or deactivation – much like I have with AMPPS on my local setup, where I can easily manage installations, updates, and toggle services. Here are a couple of screenshots for reference:

Screenshot 2024-01-08 at 15.52.40
Screenshot 2024-01-08 at 15.52.59

The essence of technology is to simplify, not complicate our lives.

After over two hours attempting this, which realistically should be a 20-second task with a simple button, I’ve decided to hire a freelancer. It’s important for me to stay focused on my main goal: developing transformative websites and apps.

Thanks again for your assistance!