手动编译PHP7的MongoDB扩展

  1. 下载支持php7的MongoDB扩展

        wget http://pecl.php.net/get/mongodb-1.1.1.tgz
        tar -zxvf mongodb-1.1.1.tgz
        cd mongodb-1.1.1.tgz
        /usr/local/php7/bin/phpize
        ./configure --with-php-config=/usr/local/php7/bin/php-config
        make && make install

    如果出现Can't install [sasl.h not found!]的错误,执行命令apt-get install libsasl2-dev

  2. 添加mongodb.so到php.ini里
  3. 查看当前扩展

        /usr/local/php7/bin/php -m
        [PHP Modules]
        bcmath
        Core
        ctype
        curl
        date
        dom
        filter
        ftp
        gd
        gettext
        hash
        iconv
        json
        libxml
        mbstring
        mcrypt
        mongodb
        mysqlnd
        openssl
        pcntl
        pcre
        PDO
        pdo_sqlite
        Phar
        posix
        Reflection
        session
        shmop
        SimpleXML
        soap
        sockets
        SPL
        sqlite3
        standard
        sysvsem
        tokenizer
        xml
        xmlreader
        xmlrpc
        xmlwriter
        Zend OPcache
        zip
        zlib
    
        [Zend Modules]
        Zend OPcache

    可以看到已经有mongodb扩展了。

标签: PHP

已有 3 条评论

  1. tingfeng-key tingfeng-key

    checking for pcre... not found
    checking Build with Cyrus SASL support... yes, shared
    checking for SASL... not found
    configure: error: sasl.h not found!

    make: *** No targets specified and no makefile found. Stop.

    1. Don Don

      the error message you got:

      configure: error: sasl.h not found!
      should be solveable by:

      sudo apt-get install libsasl2-dev
      for CentOS:

      yum install cyrus-sasl-devel
      Source:

      http://stackoverflow.com/questions/22102326/install-pecl-memcached-error

      出处见:http://askubuntu.com/questions/466345/mongo-driver-php-cant-install-sasl-h-not-found/466346

  2. centos下的mongodb扩展安装 | 宋祎超

    [...]接下来就又开始了我的探索路程,找到一个https://www.liudon.org/1322.html[...]

添加新评论