Description
Operating system: CentOS 6.X 64-bit
MongoDB Database server:
IP Address: 192.168.21.130
Web server:
IP Address: 192.168.21.127
PHP Installation path:/usr/local/php
To achieve the purpose:
Install PHP MongoDB database extensions, connect MongoDB database via PHP program
Specific actions:
First, the installation of PHP MongoDB database extensions (on the Web server 192.168.21.127 operation)
Download Address: http://pecl.php.net/get/mongo-1.6.11.tgz
Upload mongo-1.6.11.tgz to/usr/local/src directory
Tar zxvf mongo-1.6.11.tgz #解压
CD mongo-1.6.11
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make #编译
Make install #安装, the following interface appears after completion
System Yun-wei www.osyunwei.com warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
Vi/usr/local/php/etc/php.ini #编辑, add the following code on the last line
extension= "Mongo.so"
: wq! #保存退出
Service PHP-FPM Reload #重新加载php-fpm
Add a PHP test page under the site root directory
vi/usr/local/nginx/html/phpinfo.php #编辑
<?php
Phpinfo ();
?>
: wq! #保存退出
Open the page above, http://192.168.21.127/phpinfo.php
As shown in the following illustration:
Second, create test database (operate on MongoDB database server)