I have installed LAMPP on Ubuntu 16.04 LTS Server and Mongo DB installed. Now I am trying to install MongoDB driver to PHP.

sudo /opt/lampp/bin/pecl install mongo

It is throwing me the below showing error

WARNING: "pecl/mongo" is deprecated in favor of "channel:///mongodb" downloading mongo-1.6.14.tgz ...

Starting to download mongo-1.6.14.tgz (210,095 bytes)
.............................................done: 210,095 bytes
118 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no]: 
building in /tmp/pear/temp/pear-build-rootL9IHAe/mongo-1.6.14
running: /tmp/pear/temp/mongo/configure --with-php-config=/opt/lampp    
/bin/php-config --with-mongo-sasl=no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... no
configure: error: in `/tmp/pear/temp/pear-build-rootL9IHAe/mongo-1.6.14':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: `/tmp/pear/temp/mongo/configure --with-php-config=/opt/lampp     
/bin/php-config --with-mongo-sasl=no' failed

But the same command working on Ubuntu 16.04 LTS Client. Unable to fix this even after googling a lot.Looking for Solution!

  • Looks like it's looking for a working C compiler and failed to find one. Do you have gcc installed?
    – kevinadi
    Sep 15 '16 at 1:07

I have solved this problem by installing Autoconf,devssl and gcc compiler. My server is successfully running.

sudo apt install gcc
sudo apt-get install autoconf 
sudo apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
sudo apt-get install libssl-dev
sudo apt-get install build-essential

Then I have tried to install mongo extension to PHP

sudo /opt/lampp/bin/pecl install mongo

It was successfully compiled and Installed. Later I have added mongo extension to php.ini

echo 'extension=mongo.so' >> /opt/lampp/etc/php.ini

Successfully done.


I am using sudo pecl install mongodb and this is working for me. if you php version 5.6 and you check this packages sudo apt-get install -y autoconf g++ make openssl libssl-dev libcurl4-openssl-dev pkg-config libsasl2-dev libpcre3-dev

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.