Description
MongoDB is a very famous NOSQL database, the following is the installation of MongoDB under Ubuntu 14.04, as well as the configuration for PHP (driver installation, etc.), this method is applicable to Homestead.
Install MongoDB
1. Add Source
sudo apt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv 7f0ceb10
Echo ' Deb http:// Downloads-distro.mongodb.org/repo/ubuntu-upstart Dist 10gen ' | sudo tee/etc/apt/sources.list.d/mongodb.list
sudo apt-get update
2. Start Installation
You can customize the installation of Package please see here.
sudo apt-get install-qq mongodb-org
Install complete Check to open:
$ PS-EF | grep MONGO
MongoDB 15683 1 1 03:00? 00:00:37/usr/bin/mongod--config/etc/mongod.conf
Check version:
$ MONGO--version
MongoDB Shell version:2.6.6
$ MONGO
> Db.test.save ({test:100})
> Db.test.fin D ()
{"_id": ObjectId ("549253f4d91767276c02fc14"), "Test": 100}
Path information and default parameter descriptions:
Sources:/usr/bin/
Logs:/var/log/mongodb/mongod.log
Data:/var/lib/mongodb/
Default ip:127.0.0.1
Default Port MongoDB is listening:27017
All the above information can be modified by editing/etc/mongod.conf.
Open/Close
$ sudo service mongod start
$ sudo service mongod stop
$ sudo service mongod restart
Install PHP Mongodb Driver
1. Install Driver
echo "No" > Answers.txt
sudo pecl install MONGO < answers.txt
RM answers.txt
2. Open PHP Extension
echo ' extension=mongo.so ' | sudo tee/etc/php5/mods-available/mongo.ini
sudo ln-s/etc/php5/mods-available/mongo.ini/etc/php5/fpm/conf.d/ Mongo.ini
sudo ln-s/etc/php5/mods-available/mongo.ini/etc/php5/cli/conf.d/mongo.ini
Reboot the server
sudo service php5-fpm restart
Verify that the installation is successful
$ php-i | grep ' Mongo '
MongoDB Support => enabled: Sparkles:: Sparkles:: Sparkles
Thank you for reading, I hope to help you, thank you for your support for this site!