高峰之巅 发表于 2018-10-24 13:16:33

PHP7 pecl 安装 mongodb扩展 和 PHPLIB

安装PECL
  //php版本 > 7
  

$ wget http://pear.php.net/go-pear.phar  
$ php go-pear.phar
  

  //php版本 < 7
  $ yum install php-pear
  //否则会报错PHP Parse error:syntax error, unexpected //'new' (T_NEW) in /usr/share/pear/PEAR/Frontend.php on //line 91

安装扩展
  $ pecl install mongodb
  And if I try to install mongodb for example, I'll get the same warnings as before with an extra &quot;XML Extension not found&quot; at the end.
  I compared the &quot;/usr/bin/pecl&quot; with one from ubuntu and the only difference is the &quot;-n&quot; in the exec line :
  alpine:
  exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv=&quot;On&quot; $INCDIR/peclcmd.php &quot;$@&quot;
  -n meaning: &quot;No configuration (ini) files will be used&quot;
  If not using conf, xml won't be loaded, so I'm pretty sure the &quot;-n&quot; should be removed.
  I tested after removing it, and got no warning or anything and was able to install my extension.
  sumery:vi /usr/bin/peclremove -n para
  安装完毕后,添加库到php.ini
  

  
extension=mongodb.so
  

安装 PHPLIB
  http://php.net/manual/zh/mongodb.tutorial.library.php
  https://getcomposer.org/download/
  安装完毕后,安装 PHP Library for MongoDB (PHPLIB)
  $ composer require mongodb/mongodb``最新版本的命令是:$ composer.phar require mongodb/mongodb`
  一切正确后,在当前目录下,生成:vendor目录,OK


页: [1]
查看完整版本: PHP7 pecl 安装 mongodb扩展 和 PHPLIB