Search code examples
phpmongodbphp-extensionphp-7.1ubuntu-24.04

How to install mongodb PHP extension for PHP 7.1 in 2024


I did a clean install of my system and currently running Ubuntu 24.04. I have a legacy project running on PHP 7.1 which uses MongoDB so I need to install the extension for PHP 7.1.

And here comes the problem:

~ sudo apt-get install php7.1-mongodb
Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package php7.1-mongodb E: Couldn't find any package by glob 'php7.1-mongodb' E: Couldn't find any package by regex 'php7.1-mongodb'

It exists for all versions from PHP 7.2 to 8.3, but not for 7.1 which I need. Also apt install php-mongodb doesn't help because I have all PHP versions installed from 5.6 to 8.3, so it installs for my default one (PHP 8.3).

Is there any other repo which still has this package? If not, can I somehow manually install it? I have a backup of my disk before clean install so I can get the needed files from there but I need instructions what to copy where.


Solution

  • PHP 7.1 end-of-life was December 2019. Maybe you should try to install mongodb-1.6.0 which was released in September 2019: pecl install mongodb-1.6.0.