Environment Description:
centos5.6 32bit
PHP 5.2.17
PHP Installation Path/usr/local/php
Phpize Path/usr/bin
Php-config Path/usr/bin
PHP.ini Path/etc/
1. First download the PHP mongodb extension
Download the MongoDB extension source package from the Http://pecl.php.net/package/mongo URL
wget http://pecl.php.net/get/mongo-1.4.5.tgz
2. Unzip the installation package
Tar zxf mongo-1.4.5.tgz
3. Go to unzip directory and run Phpize to prepare for installation
CD mongo-1.4.5
/usr/local/php/bin/phpize
4. Install and compile
When the above command finishes running, the Configure file is generated in the directory
Use the./configure command to install the configuration, and then compile the installation using make && makes install, with the following command:
./configure--with-php-config=/usr/local/php/bin/php-config
Make && make install
5. Edit PHP.ini Add the MongoDB extension by adding the following line
Extension=mongo.so
Restart the Web container, and then look at the phpinfo and see the contents of MongoDB to indicate that the installation was successful.
Example
Server environment cent OS 5.6 32 bit, PHP version 5.2.17 compiled installation, installation path/usr/local/php
First download the latest PHP mongodb extension source code, the source code can be downloaded to the Http://pecl.php.net/package/mongo
wget http://pecl.php.net/get/mongo-1.2.0.tgz
Tar zxf http://pecl.php.net/get/mongo-1.2.0.tgz
CD mongo-1.2.0
After entering the folder, first run phpize to prepare the environment for compiling the extension, phpize the introduction of this program here
/usr/local/php/bin/phpize
The following results are performed after the run:
After running, the./configure script is generated, and this time we run the./configure script to configure
./configure--with-php-config=/usr/local/php/bin/php-config
--with-php-config This parameter is to tell the configuration script php-config the path of this program, Php-config's introduction here
The above command runs in a properly configured environment with the following results
Then compile the extension with make.
Make && make install
The correct compilation execution results are as follows (the last few lines of the compiled output)
When you're done, edit your php.ini file to add a line
Extension=mongo.so
The general default of compiling PHP INI file in
/usr/local/php/etc/php.ini
Restart your Web server or PHP-FPM, print phpinfo, if you see the following then congratulations, MongoDB's expansion installation succeeded
Linux installs MongoDB extensions to PHP