Posts

Showing posts with the label MongoDB

Install MongoDB for PHP5.4 on MAMP

Image
1. Download mongo.so from  https://github.com/stennie/mongo-php-driver/downloads 2. Copy mongo.so to MAMP PHP folder. For example, mine is at /Applications/MAMP/bin/php/ php5.4.10 /lib/php/extensions/no-debug-non-zts-20100525/ Remember to select the correct PHP version. You can check your PHP version from your MAMP start page, e.g http://localhost/MAMP/phpinfo.php 3. Enable the extension in PHP Configuration file (php.ini). You can find the path to the file from the PHPInfo (see above example). To enable, add the following line in the " Dynamic Extension " section. extension=mongo.so 4. Restart your MAMP. You should see " mongo " section in PHPinfo .

Amazon AMI install MongoDB Driver

Image
Did an installation of MongoDB driver for PHP on my Amazon EC2 AMI just now. And thought of noting the steps down. Prerequisites  Make sure the following packages are installed. $ sudo yum install gcc $ sudo yum install make $ sudo yum install httpd mod_ssl $ sudo yum install php $ sudo yum install php-devel php-pear $ sudo yum install pcre-devel Install MongoDB driver for Amazon Linux Installing Mongo driver. $ sudo pecl install mongo Enable the driver $ sudo vi /etc/php.d/mongo.ini $ extension=mongo.so $ sudo /sbin/service httpd restart Testing The simplest way to check whether the installation is successful is via phpinfo() . <?php phpinfo(); ?> And you should see the following section: Or test the connection using the code snippet below :) <?php // connect $m = new Mongo("mongodb://mongodb-user:mongodb-password@ds031087.mongolab.com:31087/sample-test-mongodb"); // select a database $db = $m->{"sample-test-mongodb...