Skip to content

Instantly share code, notes, and snippets.

@rafi
Created April 14, 2010 20:56
Show Gist options
  • Save rafi/366336 to your computer and use it in GitHub Desktop.
Save rafi/366336 to your computer and use it in GitHub Desktop.
MongoDB install
wget http://downloads.mongodb.org/linux/mong … -1.2.0.tgz
tar xvfz mongodb-linux-i686-1.2.0.tgz -C /usr/local/softnix/
mv mongodb-linux-i686-1.2.0/ mongodb
mkdir -p /data/db
ln -s /usr/local/softnix/mongodb/bin/mongod /sbin/mongod
ln -s /usr/local/softnix/mongodb/bin/mongo /bin/mongo
./mongod &
./mongo
>use syslog;
>exit
//end install
./mongod --fork --logpath /var/log/mongodb.log --logappend
=======================================
//install php mongodb
yum install gcc
yum install autoconf
ln -s /usr/local/softnix/php/bin/phpize /bin/phpize
ln -s /usr/local/softnix/php/bin/php-config /bin/php-config
cd /root
wget http://pecl.php.net/get/mongo-1.0.2.tgz
tar xvfz mongo-1.0.2.tgz
cd mongo-1.0.2
phpize
./configure
make
make install
vi /usr/local/softnix/php/lib/php.ini
mv /usr/local/softnix/php/lib/php/extensions/no-debug-non-zts-20060613/ /usr/local/softnix/php/lib/
//=============== in /usr/local/softnix/php/lib/php.ini
//change
display_errors = On
//add
extension=mongo.so
extension=wddx.so
mv /usr/local/softnix/php/lib/php/extensions/no-debug-non-zts-20060613/mongo.so /usr/local/softnix/php/lib/
mv /usr/local/softnix/php/lib/php/extensions/no-debug-non-zts-20060613/wddx.so /usr/local/softnix/php/lib/
======================================
//test php-mongo
mongod &
//create file /root/montotest.php
<?php
$m = new Mongo();
$collection = $m->selectDB( “syslog” )->selectCollection( “logs” );
$obj = $collection->insert(array(”name”=>”Pisal Kusolwatr”));
$obj = $collection->findOne();
echo “<pre>”;
var_dump($obj);
echo “</pre>”;
?>
//run
php mongotest.php
//it see look like
Sat Dec 19 22:16:25 done for 0 records 0.049secs
Sat Dec 19 22:16:24 insert syslog.logs 571ms
<pre>array(2) {
["_id"]=>
object(MongoId)#6 (0) {
}
["name"]=>
string(5) “Pisal”
}
//thats works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment