Home Backend Development PHP7 How to install mongodb extension in php7

How to install mongodb extension in php7

Aug 17, 2020 am 09:25 AM
mongodb php7

How to install the mongodb extension in php7: First download the mongodb extension file; then decompress, compile and install; then modify the php configuration file and add the "mongodb.so" extension configuration; finally restart the php-fpm service.

How to install mongodb extension in php7

Recommended: "PHP Video Tutorial"

PHP7 Add Mongodb extension and install Mongodb

When I compiled and installed php7 before, the mongo extension was not added. Now I need to debug the program and require php to support the mongo extension. Checked the relevant files and successfully installed the extension.

1: Install Mongodb

1. First download the compressed package from the official website: https://www.mongodb.com/download-center?jmp=nav#community

Unzip the package file:

tar -zxvf mongodb-osx-x86_64-enterprise-3.4.2.tgz
Copy after login

Create the specified folder and copy the code there:

mkdir -p mongodb
cp -R -n mongodb-osx-x86_64-enterprise-3.4.2/ mongodb
Copy after login

Create environment variables:

export PATH=<mongodb-install-directory>/bin:$PATH
Copy after login

Create a data folder for mongodb.

mkdir -p /data/db
Copy after login

Start the service (--dbpath specifies the data folder path):

mongod --dbpath <path to data directory>
Copy after login

2: Install the Mongodb extension

1. Download the extension file: http://pecl. php.net/package/mongodb

Decompress, compile and install:

tar -zxf mongodb-1.2.8.tgz
cd mongodb-1.2.8/
phpize
./configure --with-php-config=/urs/bin/php-config
make && make install
Copy after login

Modify the php configuration file and add the mongodb.so extension configuration

vim /etc/php.ini
extension=mongodb.so
Copy after login

Restart the php-fpm service

service php-fpm restart
Copy after login

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

How to make PHP5.6 and PHP7 coexist through Nginx configuration on the same server? How to make PHP5.6 and PHP7 coexist through Nginx configuration on the same server? Apr 01, 2025 pm 03:15 PM

Running multiple PHP versions simultaneously in the same system is a common requirement, especially when different projects depend on different versions of PHP. How to be on the same...

How to configure MongoDB automatic expansion on Debian How to configure MongoDB automatic expansion on Debian Apr 02, 2025 am 07:36 AM

This article introduces how to configure MongoDB on Debian system to achieve automatic expansion. The main steps include setting up the MongoDB replica set and disk space monitoring. 1. MongoDB installation First, make sure that MongoDB is installed on the Debian system. Install using the following command: sudoaptupdatesudoaptinstall-ymongodb-org 2. Configuring MongoDB replica set MongoDB replica set ensures high availability and data redundancy, which is the basis for achieving automatic capacity expansion. Start MongoDB service: sudosystemctlstartmongodsudosys

How to ensure high availability of MongoDB on Debian How to ensure high availability of MongoDB on Debian Apr 02, 2025 am 07:21 AM

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

Comparison of Redis queues and MySQL stability: Why is Redis prone to data loss? Comparison of Redis queues and MySQL stability: Why is Redis prone to data loss? Apr 01, 2025 pm 02:24 PM

Comparison of Redis queues and MySQL stability: Why is Redis prone to data loss? In the development environment, using PHP7.2 and ThinkPHP frameworks, we often face the choice of cooperation...

Navicat's method to view MongoDB database password Navicat's method to view MongoDB database password Apr 08, 2025 pm 09:39 PM

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

How to avoid manually modifying the permissions of unixsocket after each system restart? How to avoid manually modifying the permissions of unixsocket after each system restart? Apr 01, 2025 pm 12:54 PM

How to avoid manually modifying the permissions of unixsockets after each system restart. In Unix systems, sometimes you will need to manually modify a certain...

See all articles