mac php添加mongodb扩展

1、下载安装mongo驱动扩展包

$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule update --init
$ phpize
$ ./configure
$ make all
$ sudo make install

2、修改php.ini,

sudo vi /usr/local/php/lib/php.ini

添加

extension=mongodb.so

不知道php.ini位置的可以这样找

normanyangtekiMacBook-Pro:mongo-php-driver normanyang$ php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File:         /usr/local/php/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

3、重启apache

sudo apachectl restart

4、查看php当前支持

php -m

[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
memcache
memcached
mongodb
mysql

可以看到mongodb已经支持

5、如果你在laravel里面开发,添加mongdb支持

composer require jenssegers/mongodb:3.0.2

 

你可能感兴趣的:(php,Linux)