Installing MongoDB
1. Download and unzip the MongoDB (download directory for/opt)
Executing commands in the/OPT directory
wget fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz
Tar xzvf mongodb-linux-x86_64-2.6.4.tgz
2. creating MongoDB data files and log file storage paths
Mkdir-p/data/mongodb_data/{mongodb_log,mongodb_db}
Create a data file path/data/mongodb_data/mongodb_db
Create log file path/data/mongodb_data/mongodb_log
3. start MongoDB
Execute Start command
/opt/mongodb-linux-x86_64-2.6.4/bin/mongod--dbpath=/data/mongodb_data/mongodb_db--logpath=/data/mongodb_data/ Mongodb_log/mongodb.log--logappend
4. Check MongoDB boot
View MongoDB default Port 27017
NETSTAT-APN | grep 27017
Look for the following tips:
TCP 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 5841/mongod
UNIX 2 [ACC] STREAM LISTENING 135359486 5841/mongod/tmp/mongodb-27017.sock
MongoDB has started successfully
You can now operate with the MONGO client.
Configure the PHP plugin to install MongoDB
1. Check the PHP tool
To increase the mongodb extension of PHP, you need to determine the path of phpsize, Php-config,pkill,php-fpm,php.ini
2. download MongoDB PHP plugin code, unzip
wget Https://github.com/mongodb/mongo-php-driver/archive/master.zip
MV Master mongodb_php
Unzip mongodb_php
PHP MongoDB Extension code folder is Mongo-php-driver-master
3. compiling the installation
Go to the MongoDB folder
Cd/opt/mongo-php-driver-master
To execute a compile command
/usr/bin/phpize
./configure--enable-mongo=share--with-php-config=/usr/local/php/bin/php-config
Make && make install
4 Modify PHP configuration file
Edit/usr/local/php/etc/php.ini Add the following statement
[MongoDB]
Extension=mongo.so
5 View Phpinfo
Restart PHP-FPM
Pkill PHP-FPM
/usr/local/php/sbin/php-fpm
If you do not see a configuration entry for MongoDB and the compilation is successful, review the configuration entries for configure.
Configuring the Python plugin for MongoDB
1. download MongoDB PHP plugin code, unzip
Cd/opt
wget Https://github.com/mongodb/mongo-python-driver/archive/master.zip
MV Master Mongodb_python
Unzip Mongodb_python
Mongodb_python Extension Code folder is Mongo-python-driver-master
2. compiling the installation
Go to the MongoDB folder
Cd/opt/mongo-pyton-driver-master
To execute a compile command
Python setup.py Install
If the compilation error occurs, check to see if your Linux gcc suite is fully installed
3. Test Python MONGO module installation
Enter the Python shell
Python
In the Python shell
Execute command
Import Pymongo
Dir (Pymongo)
The above two commands are correctly output and the installation works well.