In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to install the extension of mongodb in PHP under mac. The article is very detailed and has a certain reference value. Interested friends must finish reading it!
Mac install php mongodb method: 1, download php mongodb extension; 2, extract the installation package; 3, enter the unzipped directory, run phpize, prepare the environment for the installation of expansion; 4, install and compile mongodb php extension; 5, add mongodb extension in the extension area.
Operating environment of this article: macOS10.13.3 system, mongodb1.4.3&&PHP7.1.16 version, MacBook Air 2019 computer
Extensions to install mongodb for PHP under mac:
The phpize path is / usr/local/php/bin/phpize.
The php-config path is / usr/local/php/bin/php-config.
1.
Download mongodb's extended source package from http://pecl.php.net/package/mongodb (note: do not download from http://pecl.php.net/package/mongo, because the package has expired), and execute the following command on the command line:
Wget http://pecl.php.net/get/mongodb-1.4.3.tgz
two。 Extract the installation package
Tar-zxvf mongodb-1.4.3.tgz
3. Go to the unzipped directory and run phpize to prepare the environment for installing the extension
Cd mongodb-1.4.3 / usr/local/php/bin/phpize
4. Install the php extension that compiles mongodb
After the completion of step 3, the configure file is generated in the current directory. Next, use the. / configure command to install and configure; then, use make & & make install to compile and install, as follows:
. / configure-- with-php-config=/usr/local/php/bin/php-config make & & make install
5. Check to see if the .so extension file has been generated in the PHP extension directory
Php-I | grep extension_dir / / View the PHP expansion pack storage directory, here is extension_dir = > / usr/local/lib/php/pecl/20160303 = > / usr/local/lib/php/pecl/20160303ls / usr/local/lib/php/pecl/20160303 / / check whether there are mongodb.so files in the directory
6. Edit php.ini to add mongodb extensions in the extension area
Extension=mongodb.so
Note: the name of the extension is mongodb.so, not mongo.so.
7. Check to see if the mongodb expansion module for PHP has been installed successfully
Php-m | grep mongodb
If you see mongodb in the direct result, the installation has been successful.
Or, restart php-fpm and execute the phpinfo () method. If you see the contents of mongodb, the installation is successful.
8. Using mongodb extensions in PHP
After installing the mongodb extension for PHP, add "mongodb/mongodb": "^ 1.4" to the require block of the composer.json file. Then, load the expansion pack for the mongodb PHP version client through the composer command, as follows:
Composer require mongodb/mongodb
Using version ^ 1.4 for mongodb/mongodb./composer.json has been updatedLoading composer repositories with package informationUpdating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1-mongodb/mongodb 1.4.2 requires ext-mongodb ^ 1.5.0-> the requested PHP extension mongodb has the wrong version (1.4.3) installed. -mongodb/mongodb 1.4.2 requires ext-mongodb ^ 1.5.0-> the requested PHP extension mongodb has the wrong version (1.4.3) installed. -mongodb/mongodb 1.4.1 requires ext-mongodb ^ 1.5.0-> the requested PHP extension mongodb has the wrong version (1.4.3) installed. -mongodb/mongodb 1.4.0 requires ext-mongodb ^ 1.5.0-> the requested PHP extension mongodb has the wrong version (1.4.3) installed. -Installation request for mongodb/mongodb ^ 1.4-> satisfiable by mongodb/mongodb [1.4.0,1.4.1,1.4.2]. To enable extensions, verify that they are enabled in your .ini files:-/ usr/local/etc/php/7.1/php.ini-/ usr/local/etc/php/7.1/conf.d/ext-opcache.ini You can also run `php-- ini` inside terminal to see which files are used by PHP in CLI mode.Installation failed, reverting. / composer.json to its original content.
The analysis found that the version of the mongodb extension installed was too low. So, change it to version 1.5.3 (mongodb-1.5.3.tgz), do it again, and load the extension pack for the mongodb PHP version client again with the composer command. The specific information is as follows:
Sing version ^ 1.4 for mongodb/mongodb./composer.json has been updatedLoading composer repositories with package informationUpdating dependencies (including require-dev) Package operations: 5 installs, 12 updates 1 removal-Removing aliyuncs/oss-sdk-php (v2.3.0)-Updating league/flysystem (1.0.48 = > 1.0.49): Downloading (100%)-Installing ralouphie/getallheaders (2.0.5): Loading from cache-Updating guzzlehttp/psr7 (1.4.2 = > 1.5.0): Checking out 53662d6688-Installing symfony/contracts (v1.0.1): Downloading (100%)-Updating symfony/translation (v4.1.7 = > v4.2 .0): Checking out ff9a878c9b-Updating nesbot/carbon (1.34.3 = > 1.36.1): Checking out 63da8cdf89-Updating symfony/dom-crawler (v4.1.7 = > v4.2.0): Checking out 7438a32108-Updating symfony/browser-kit (v4.1.7 = > v4.2.0): Checking out db7e59fec9-Updating symfony/console (v4.1.7 = > v4.2.0): Checking out 4dff24e5d0-Updating symfony/css-selector (v4.1) .7 = > v4.2.0): Checking out aa9fa526ba-Updating symfony/event-dispatcher (v4.1.7 = > v4.2.0): Checking out 9b788b5f7c-Updating symfony/finder (v4.1.7 = > v4.2.0): Checking out e53d477d7b-Updating symfony/process (v4.1.7 = > v4.2.0): Checking out 2b341009cc-Updating symfony/yaml (v4.1.7 = > v4.2.0): Checking out c41175c801-Installing library/aliyun-oss -php-sdk (v2.3.0): Cloning 6e801c85b9 from cache- Installing mongodb/mongodb (1.4.2): Downloading (100%)-Installing justinrainbow/json-schema (5.2.7): Downloading (100%) symfony/contracts suggests installing psr/cache (When using the Cache contracts) symfony/contracts suggests installing psr/container (When using the Service contracts) symfony/contracts suggests installing symfony/cache-contracts-implementation () symfony/contracts suggests installing symfony/service-contracts-implementation () Package phpunit/dbunit is abandoned You should avoid using it. No replacement was suggested.Writing lock fileGenerating autoload files above is all the contents of this article entitled "how to install mongodb extensions for PHP under mac". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.