Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer does not install mongodb ubuntu

I ran: composer require mongodb/mongodb. But it gave me the following error :

has error:

- mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
- mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
- Installation request for mongodb/mongodb ^1.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].

I tried : composer show -p

Then it gave me:

......
ext-iconv           0         The iconv PHP extension
ext-mcrypt          0         The mcrypt PHP extension
ext-mhash           0         The mhash PHP extension
ext-mongo           1.6.12    The mongo PHP extension
ext-mysql           1.0       The mysql PHP extension
ext-mysqli          0.1       The mysqli PHP extension
......

Why am I getting the error?

php -m

..... 
libxml 
mbstring 
mcrypt 
mhash 
mongo 
mysql 
mysqli 
openssl 
pcntl
pcre
 PDO 
 .....

I'm using ubuntu 14.04 LTS

like image 888
Vagabond Avatar asked Mar 10 '16 05:03

Vagabond


People also ask

How do I know if MongoDB is installed on Ubuntu?

MongoDB installs as a systemd service, which means that you can manage it using standard systemd commands alongside all other sytem services in Ubuntu. To verify the status of the service, type: sudo systemctl status mongodb.


3 Answers

  1. Install the php driver $ sudo pecl install mongodb
  2. Create the extension file $ sudo nano /etc/php/*version*/mods-available/mongodb.ini and write inside: extension=mongodb.so
  3. Create a symbolic link for this file $ sudo ln -sv /etc/php/*version*/mods-available/mongodb.ini /etc/php/*version*/apache2/conf.d/20-mongodb.ini
  4. Create an other symbolic link for this file $ sudo ln -sv /etc/php/*version*/mods-available/mongodb.ini /etc/php/*version*/cli/conf.d/20-mongodb.ini
  5. Restart apache or the server used $ sudo service apache2 restart

It may be necessary to reinstall jenssegers/mongodb: $ composer require jenssegers/mongodb

like image 58
J.C. Gras Avatar answered Oct 17 '22 01:10

J.C. Gras


for quick and easy, just do:

  • sudo pecl install mongodb
  • sudo nano /etc/php5/apache2/php.ini, add (at bottom or wherever):

; mongodb extension=mongodb.so

  • sudo nano /etc/php5/cli/php.ini, add (at bottom or wherever):

; mongodb extension=mongodb.so

  • restart webserver for good measure (not necessary for cli): sudo service apache2 restart
like image 30
Eva Avatar answered Oct 17 '22 01:10

Eva


i'm run:

sudo apt-get install libpcre3-dev

then:

pecl install mongodb

and add: extension=mongodb.so to bottom line of cli/php.ini

like image 4
Vagabond Avatar answered Oct 17 '22 01:10

Vagabond