пятница, 25 февраля 2011 г.

Installation mongodb+php on Ubuntu/Debian

By looking in internet for way to install mongodb driver I have found only truncated instructions. And there will be my complete guide :)

First of all we need to install mongodb server:
 sudo aptitude install mongodb  
And try whether it works:
 $ mongo  
 MongoDB shell version: 1.6.6-pre-  
 connecting to: test  
 > show dbs  
 admin  
 local  
Now we can install pear
 sudo apt-get install php5-dev php-pear  
and download & install mongodb driver for php
 sudo pecl install mongo
now we have to create file /etc/php5/conf.d/mongo.ini and write 1 line in it
 extension=mongo.so  
restart apache
 sudo /etc/init.d/apache2 restart  
and try some php code like that:
 <?php
 var_dump(new Mongo());  
in my case output was
 object(Mongo)#1 (4) {  
  ["connected"]=&gt;  
  bool(true)  
  ["status"]=&gt;  
  NULL  
  ["server":protected]=&gt;  
  string(0) ""  
  ["persistent":protected]=&gt;  
  NULL  
 }  

Комментариев нет:

Отправить комментарий