我跑了:composer require mongodb/mongodb
。但它给了我以下错误:
有错误:
- mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system. - mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system. - Installation request for mongodb/mongodb ^1.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
我试过了:composer show -p
然后它给了我:
......
ext-iconv 0 The iconv PHP extension
ext-mcrypt 0 The mcrypt PHP extension
ext-mhash 0 The mhash PHP extension
ext-mongo 1.6.12 The mongo PHP extension
ext-mysql 1.0 The mysql PHP extension
ext-mysqli 0.1 The mysqli PHP extension
......
为什么我收到错误?
php -m
.....
libxml
mbstring
mcrypt
mhash
mongo
mysql
mysqli
openssl
pcntl
pcre
PDO
.....
我正在使用ubuntu 14.04 LTS
答案 0 :(得分:15)
$ sudo pecl install mongodb
$ sudo nano /etc/php/*version*/mods-available/mongodb.ini
并在里面写: extension = mongodb.so $ sudo ln -sv /etc/php/*version*/mods-available/mongodb.ini /etc/php/*version*/apache2/conf.d/20-mongodb.ini
$ sudo ln -sv /etc/php/*version*/mods-available/mongodb.ini /etc/php/*version*/cli/conf.d/20-mongodb.ini
$ sudo service apache2 restart
可能需要重新安装jenssegers / mongodb:$ composer require jenssegers/mongodb
答案 1 :(得分:7)
快捷方便,只需:
sudo pecl install mongodb
sudo nano /etc/php5/apache2/php.ini
,添加(在底部或任何地方): ; mongodb
extension=mongodb.so
sudo nano /etc/php5/cli/php.ini
,添加(在底部或任何地方): ; mongodb
extension=mongodb.so
sudo service apache2 restart
答案 2 :(得分:4)
我跑:
sudo apt-get install libpcre3-dev
然后:
pecl install mongodb
并将extension=mongodb.so
添加到cli/php.ini