MongoClient无法使用php 7.2(OS- Ubuntu 16.04)

时间:2018-12-05 18:41:36

标签: php mongodb ubuntu-16.04

我尝试了此代码,但无法正常工作

<?php
$connection=new MongoClient();
?>

然后也尝试使用:-

<?php
$connection=new MongoClient("mongodb://localhost:27017");
?>

我的mongodb版本

pratish@pratish-HP-Notebook:~$ mongod -version
db version v3.6.9
git version: 167861a164723168adfaaa866f310cb94010428f
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

我的php版本

pratish@pratish-HP-Notebook:~$ php -version
PHP 7.2.12-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Nov 12 2018 09:55:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.12-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

和mongodb在php中的扩展名

pratish@pratish-HP-Notebook:~$ php -i | grep extension_dir
extension_dir => /usr/lib/php/20170718 => /usr/lib/php/20170718
pratish@pratish-HP-Notebook:~$ cd /usr/lib/php/20170718/
pratish@pratish-HP-Notebook:/usr/lib/php/20170718$ ls
build        gd.so        mysqli.so     readline.so   tokenizer.so
calendar.so  gettext.so   mysqlnd.so    shmop.so      wddx.so
ctype.so     iconv.so     opcache.so    simplexml.so  xmlreader.so
dom.so       json.so      pdo_mysql.so  sockets.so    xml.so
exif.so      mbstring.so  pdo.so        sysvmsg.so    xmlwriter.so
fileinfo.so  mcrypt.so    phar.so       sysvsem.so    xsl.so
ftp.so       mongodb.so   posix.so      sysvshm.so
mongodb is running in info.php file

请提出解决方案,我对mongodb不满意

0 个答案:

没有答案