This article will tell me about the process of installing MONGODB extension, you can refer to
Installation Environment
Linux Environment: CentOS 6.5
Apache Version: 2.4
PHP Version: 5.4.3
MongoDB version: 2.6.5
One, download mongo-php extension installation package
Can be downloaded from GitHub, address is https://github.com/mongodb/mongo-php-driver-legacy
Download the files to a random directory and unzip them.
You need to install a series of compilation tools before installation, you can skip this step if you have already installed.
Installing the Build Tool
Yum Install GCC gcc-c++ autoconf automake
Make: * * [Io_stream.lo] Error 1 errors may appear in the Do all step.
So we need to install Openssl-devel.
Yum Install Openssl-devel
At this point, all the pre-work is ready.
Second, compile and install mongo-php extension
The file name of the mongo-php extension file I downloaded is mongo-php-driver-legacy-master.zip and placed in the/home/demon directory.
Unzip Mongo-php-driver-legacy-master.zip to mongo-php. Then go to the mongo-php directory
Unzip -Q Mongo-php-driver-legacy-master. Zip mv mongo-php-driver-legacy-master mongo-phpcd MONGO-phpphpize. /Configure make all makeinstall
If there is no problem during the installation, the PHP driver directory will appear after make install, for example:
Installing shared extensions: /usr/lib64/php/modules/
To load this extension when PHP is started, add the following code to the/etc/php.ini:
[Mongodb]extension=mongo.so
Third, restart Apache service
Service httpd Restart
Output phpinfo (); If you see MONGO, the installation is successful.
Iv. Testing the PHP code to connect MongoDB
<? PHP Try { $connnew Mongo (' 127.0.0.1 ');} Catch (Exception$e) { echo$e, GetMessage ();}
If failed to connect To:127.0.0.1:27017:permission denied appears, then run the following statement to resolve
1 Service httpd Restart
PHP Install MongoDB Extension