Download wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.4.tgz
Decompress the package to/usr/local/Mongo.
Create a configuration file
Mkdir-P/usr/local/Mongo/etc/usr/local/Mongo/data/usr/local/Mongo/log // usr/local/Mongo/Repair
Vim/usr/local/Mongo/etc/Mongo. conf
Add the following content to Mongo. conf.
Dbpath =/usr/local/Mongo/Data
Logpath =/usr/local/Mongo/MongoDB. Log
Repairpath =/usr/local/Mongo/Repair
Pidfilepath =/usr/local/Mongo/MongoDB. PID
Directoryperdb = true
Logappend = true
Noauth = true
Port = 27017
Maxconns = 1024
Fork = true
Rest = true
Quota = true
Quotafiles = 1024.
Nssize = 16
Start MongoDB
Ln-S/usr/local/Mongo/bin/mongod/usr/bin/mongod
Mongod-F/usr/local/Mongo/etc/Mongo. conf
Check whether it is started, but it is unwise to use this method to manage the MongoDB server. Let's improve it:
Mkdir-P/usr/local/Mongo/srv
Vim/usr/local/Mongo/srv/MongoDB-start
Add the following content
#! /Bin/sh
Mongod-F/usr/local/Mongo/etc/Mongo. conf
Vim/usr/local/Mongo/srv/MongoDB-stop
Add the following content
#! /Bin/bash
PID = 'ps-o pid, command ax | grep mongod | awk '! /Awk /&&! /Grep/{print $1 }'';
If ["$ {pid }"! = ""]; Then
Kill-2 $ {pid };
Fi
Add execution permission
Chmod A + x/usr/local/Mongo/srv/MongoDB-start
Chmod A + x/usr/local/Mongo/srv/MongoDB-stop
Vim/etc/rc. d/init. d/MongoDB
Add the following content
#! /Bin/sh
#
# MongoDB-this script starts and stops the MongoDB daemon
#
# Chkconfig:-85 15
# Description: MongoDB is a non-relational database storage system.
# Processname: MongoDB
# Config:/usr/local/Mongo/etc/Mongo. conf
# Pidfile:/usr/local/Mongo/MongoDB. PID
Path =/usr/local/Mongo/bin:/sbin:/bin:/usr/sbin:/usr/bin
Name = MongoDB
Test-x $ daemon | exit 0
Set-e
Case "$1" in
Start)
Echo-n "Starting MongoDB ..."
/Usr/local/Mongo/srv/MongoDB-start
;;
Stop)
Echo-n "Stopping MongoDB ..."
/Usr/local/Mongo/srv/MongoDB-stop
;;
*)
N =/etc/init. d/$ name
Echo "Usage: $ n {START | stop}"> & 2
Exit 1
;;
Esac
Exit 0
Add Service
Chmod A + x/etc/rc. d/init. d/MongoDB
Chkconfig -- add MongoDB
Chkconfig -- level 345 MongoDB on
/Etc/rc. d/init. d/MongoDB start
PHP Mongo extension installation:
64-bit cent OS 5.6 server environment, PHP 5.2.17 compiling and installation, installation path/usr/local/PHP
First download the latest PHP MongoDB extension source code. The source code can be downloaded at http://pecl.php.net/package/#to
Wget http://pecl.php.net/get/mongo-1.2.2.tgz
Tar zxf mongo-1.2.2.tgz
CD mongo-1.2.2
After entering the folder, first run phpize to prepare the compiling extension environment. Here is the introduction of phpize.
/Usr/local/PHP/bin/phpize
The execution result is as follows:
Processing ing:
Php api version: 20041225
Zend module api no: 20060613
Zend extension api no: 220060519
After running, the./configure script is generated. At this time, we run the./configure script for configuration.
./Configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config
-- With-PHP-config indicates the path of the configuration script PHP-config.
The preceding command runs in a correctly configured environment and the result is as follows:
Creating libtool
Appending configuration tag "cxx" to libtool
Configure: Creating./config. Status
Config. Status: Creating config. h
In this case, make is used to compile the extension.
Make & make install
The correct compilation and execution results are as follows:
Build complete.
Don't forget to run 'make test '.
Installing shared extensions:/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/
After editing, add a line to your php. ini file.
Extension = Mongo. So
The default php ini file is
/Usr/local/PHP/etc/PHP. ini
Restart your web server or PHP-FPM and print phpinfo. If you see the Mongo entry table, the MongoDB extension is successfully installed.