2
votes

I am newbie to php , I am trying to run laravel project with mongodb , but i am unable to install mongodb 1.60 php driver

Your requirements could not be resolved to an installable set of packages. Problem 1 - mongodb/mongodb 1.6.0 requires ext-mongodb ^1.7 -> the requested PHP extension mongodb has the wrong version (1.3.4) installed. - Installation request for mongodb/mongodb 1.6.0 -> satisfiable by mongodb/mongodb[1.6.0].

I tried this command

sudo apt-get install php-mongodb

this commands installs mongodb php-mongodb_1.3.4-1build1 .

when i tried to install 1.6 , response says 1.6 version not found

sudo apt-get install php-mongodb E: Version '1.6' for 'php-mongodb' was not found

can anyone please help here.

2

2 Answers

2
votes

So the mongodb/mongodb package is a php package, when you're doing the laravel install via composer, it's throwing an error stating it needs the 1.6.0 version of that package.

The problem is it requires your server php to have the ext-mongodb ^1.7 extension.

It currently has the 1.3.4 version.

You can see how to install it here: https://docs.mongodb.com/drivers/php

-1
votes

The problem is a mismatch of packages being installed

You could consider removing the packages and installing them as detailed on this page [https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/][1]

See below for ubuntu 18.04 Remove old mongodb packages

sudo apt-get purge mongodb* 

Add the correct repo

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list

update

sudo apt-get update

Install the new package

sudo apt-get install -y mongodb-org
sudo rm -rf /tmp/mongodb-27017.sock                                             
sudo rm -f /var/lib/mongo/mongod.lock                                           
sudo rm -f /var/run/mongodb/mongod.pid                                          
touch /var/run/mongodb/mongod.pid                                               
sudo chown -R  mongodb:mongodb /var/run/mongodb/                                
sudo chown mongodb:mongodb /var/run/mongodb/mongod.pid                          
sudo systemctl start mongod   

Install the correct driver for mongo (note the php-version 7.2)

sudo apt-get install php7.2-mongodb