Home > php教程 > PHP开发 > Detailed introduction to installing MongoDB and PHP MongoDB Driver in Ubuntu 14.04

Detailed introduction to installing MongoDB and PHP MongoDB Driver in Ubuntu 14.04

高洛峰
Release: 2016-12-23 09:14:27
Original
1371 people have browsed it

Instructions

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 suitable for Homestead.

Install MongoDB

1. Add the 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
Copy after login

2. Start the installation

You can customize the installation package here.

sudo apt-get install -qq mongodb-org

Check if the installation is complete:

$ 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.find()
{ "_id" : ObjectId("549253f4d91767276c02fc14"), "test" : 100 }
Copy after login

Path information and default parameter description:

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
Copy after login

The above information can be modified by editing /etc/mongod.conf.

Turn on/off

$ sudo service mongod start
$ sudo service mongod stop
$ sudo service mongod restart
Copy after login

Install PHP Mongodb Driver

1. Install Driver

echo "no" > answers.txt
sudo pecl install mongo < answers.txt
rm answers.txt
Copy after login

2. Enable PHP extension

echo &#39;extension=mongo.so&#39; | 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
Copy after login

Restart the server

sudo service php5 -fpm restart

Verify whether the installation is successful

$ php -i | grep &#39;Mongo&#39;
MongoDB Support => enabled
:sparkles: :sparkles: :sparkles:
Copy after login

Thank you for reading, I hope it can help everyone, thank you everyone for supporting this site!

For more Ubuntu 14.04 installation MongoDB and PHP MongoDB Driver detailed introduction and related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template