How to install mongodb php extension

藏色散人
Release: 2023-03-01 22:00:01
Original
3031 people have browsed it

How to install the mongodb php extension: first open the download address and download the "php-mongodb" extension; then compile and install it; finally add the mongo configuration in the "php.ini" file.

How to install mongodb php extension


# 1: Download mongodb www.mongodb.org Download the latest stable version

2: Unzip the file

3: No need to compile, it is a compiled binary executable file.

4: Start mongod service

./bin/mongod --dbpath /path/to/database --logpath /path/to/log --fork --port 27017
Copy after login

Parameter explanation:

--dbpath data storage directory

--logpath log storage directory

--port run Port (default 27017)

--fork background process running

./bin/mongod –dbpath /home/mdb –logpath /home/mlog/m1.log –fork –port 27017 – smallfiles

./bin/mongo

#Connect to server:

Mongodb php extensions

pecl.php.net

  1. 2. Download php-mongodb extension

3. Mongodb-1.1.6 download address:

http:/ /pecl.php.net/get/mongo-1.6.13.tgz

4. Compilation and installation:

$ tar zxvf mongodb -mongodb-php-driver- .tar.gz $ cd mongodb-mongodb-php-driver-

[root@localhost mongo-1.6.13]# /usr/local /php5.6/bin/phpize

[root@localhost mongo-1.6.13]# ./configure --with-php-config=/usr/local/php5.6/bin/php-config

[root@localhost mongo-1.6.13]# make && make install


After successful compilation:


##/usr/local/php5.6/lib/php/extensions/no-debug-non-zts-20131226/

5

, find

php.ini

file:

find / -name php.iniVim /etc/php.ini##Add a line:extension=/usr/ local/php5.6/lib/php/extensions/no-debug-non-zts-20131226/

mongo.so

Execute After the above command, you need to modify thephp.inifile and addmongo in the

php.inifileConfiguration, the configuration is as follows:##Note:You need to specify the

extension_dirpath to the configuration item.

6. Finally check whether phpinfo() is installed successfully:

For more related knowledge, please visitPHP Chinese website!

The above is the detailed content of How to install mongodb php extension. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!