Activities

April 2015
M T W T F S S
« Mar   May »
 12345
6789101112
13141516171819
20212223242526
27282930  

Installing Mongodb PHP extension in Ubuntu/CentOS Linux

One of the new projects using Mongodb as database for push notification and it’s library support to be enabled on the PHP as well. After googling, it is found that we can get the mongodb php driver from the GitHub repository and we need to install manually.

Then only challenge I’m facing is, My server has different versions of PHP and hence I can use pear type package installer because of that. So I need to build to Mongo-php driver source code which will match aganist my custom php installation.

My Custom php install folder in /usr/local/php54/”

Installation steps

root@164:~# wget https://github.com/mongodb/mongo-php-driver/archive/master.zip
root@164:~# unzip master.zip
root@164:~# cd mongo-php-driver-master/
root@164:~# /usr/local/php54/bin/phpize
root@164:~# ./configure --with-php-config=/usr/local/php54/bin/php-config
root@164:~# make && make install

This will automatically add “mongo.so” entry in “/etc/php.ini” file.

root@164:~# cat /etc/php.ini| grep "mongo.so"
extension=mongo.so
root@164:~#

How do I check it

root@164:~# php -r 'phpinfo();' | grep "mongo"
mongo
mongo.allow_empty_keys => 0 => 0
mongo.chunk_size => 261120 => 261120
mongo.cmd => $ => $
mongo.default_host => localhost => localhost
mongo.default_port => 27017 => 27017
mongo.is_master_interval => 15 => 15
mongo.long_as_object => 0 => 0
mongo.native_long => 1 => 1
mongo.ping_interval => 5 => 5
root@64:~#

mongo

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>