【问题标题】:PHP 7.0.6 // MongoDB Driver - CLI works; Web does notPHP 7.0.6 // MongoDB 驱动程序 - CLI 有效;网页没有
【发布时间】:2016-09-16 14:14:04
【问题描述】:

我的新 PHP 7 安装在命令行中加载并与 mongodb 驱动程序配合得很好。

但是当我尝试查看与网页相同的资源时,驱动程序无法加载(并且我得到了伴随该失败的错误,pe: Class 'MongoDB\Driver\Query' not found ")。

不知道为什么 Apache、php 和 mongodb 驱动程序不能一起工作。这是deets:

我正在运行 Apache 2.4.18...

httpd -v

Server version: Apache/2.4.18 (Amazon)
Server built:   Mar  7 2016 22:32:11

还有 PHP 7.0.6 (remi repo)...

PHP 命令行

PHP 7.0.6 (cli) (built: Apr 28 2016 21:34:10) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

phpinfo() 确认:版本、php.ini 位置和 extension_dir 是我希望找到它们的位置...

phpinfo()

PHP Version 7.0.6
Loaded Configuration File /etc/opt/remi/php70/php.ini
extension_dir /opt/remi/php70/root/usr/lib64/php/modules

我已将扩展名添加到加载的 ini 文件中...

/etc/opt/remi/php70/php.ini

[mongo]
extension=mongodb.so

我已经确认该扩展的 lib 是 php 期望的位置...

ls -la /opt/remi/php70/root/usr/lib64/php/modules/mongodb.so

[redacted] /opt/remi/php70/root/usr/lib64/php/modules/mongodb.so

pecl 说 PEAR 是最新的...

pecl 帮助版本

PEAR Version: 1.10.1
PHP Version: 7.0.6
Zend Engine Version: 3.0.0

yum 安装 php70-php-pecl-mongodb

Loaded plugins: update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package php70-php-pecl-mongodb.x86_64 0:1.1.6-2.el7.remi will be installed
--> Processing Dependency: mongo-c-driver(x86-64) >= 1.3.5 for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.2)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.1)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.0)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libsasl2.so.3()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libmongoc-priv.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Running transaction check
---> Package mongo-c-driver.x86_64 0:1.3.5-1.el7.remi will be installed
--> Processing Dependency: mongo-c-driver-libs(x86-64) = 1.3.5-1.el7.remi for package: mongo-c-driver-1.3.5-1.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0()(64bit) for package: mongo-c-driver-1.3.5-1.el7.remi.x86_64
---> Package php70-php-pecl-mongodb.x86_64 0:1.1.6-2.el7.remi will be installed
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.2)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.1)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.0)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libsasl2.so.3()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libmongoc-priv.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Finished Dependency Resolution
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0(LIBBSON_1.2)(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libsasl2.so.3()(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0()(64bit)
Error: Package: mongo-c-driver-1.3.5-1.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0()(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libmongoc-priv.so.0()(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0(LIBBSON_1.0)(64bit)
Error: Package: mongo-c-driver-1.3.5-1.el7.remi.x86_64 (remi-safe)
           Requires: mongo-c-driver-libs(x86-64) = 1.3.5-1.el7.remi
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0(LIBBSON_1.1)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

rpm -qa php* |排序

php70-1.0-4.el6.remi.x86_64
php70-php-cli-7.0.6-3.el6.remi.x86_64
php70-php-common-7.0.6-3.el6.remi.x86_64
php70-php-devel-7.0.6-3.el6.remi.x86_64
php70-php-fpm-7.0.6-3.el6.remi.x86_64
php70-php-gd-7.0.6-3.el6.remi.x86_64
php70-php-json-7.0.6-3.el6.remi.x86_64
php70-php-mbstring-7.0.6-3.el6.remi.x86_64
php70-php-mcrypt-7.0.6-3.el6.remi.x86_64
php70-php-mysqlnd-7.0.6-3.el6.remi.x86_64
php70-php-opcache-7.0.6-3.el6.remi.x86_64
php70-php-pdo-7.0.6-3.el6.remi.x86_64
php70-php-pear-1.10.1-4.el6.remi.noarch
php70-php-pecl-amqp-1.7.0-1.el6.remi.x86_64
php70-php-pecl-apcu-5.1.4-1.el6.remi.x86_64
php70-php-pecl-apcu-bc-1.0.3-1.el6.remi.x86_64
php70-php-pecl-apcu-devel-5.1.4-1.el6.remi.x86_64
php70-php-pecl-apfd-1.0.1-5.el6.remi.x86_64
php70-php-pecl-apm-2.1.1-1.el6.remi.x86_64
php70-php-pecl-bitset-3.0.0-1.el6.remi.x86_64
php70-php-pecl-cassandra-1.1.0-1.el6.remi.x86_64
php70-php-pecl-couchbase2-2.2.0-0.1.beta2.el6.remi.x86_64
php70-php-pecl-crypto-0.2.2-1.el6.remi.x86_64
php70-php-pecl-eio-2.0.0-0.4.RC3.el6.remi.x86_64
php70-php-pecl-env-0.2.1-1.el6.remi.x86_64
php70-php-pecl-ev-1.0.0-1.el6.remi.x86_64
php70-php-pecl-event-2.0.4-1.el6.remi.x86_64
php70-php-pecl-fann-1.1.0-1.el6.remi.x86_64
php70-php-pecl-gender-1.1.0-6.el6.remi.x86_64
php70-php-pecl-geoip-1.1.0-9.el6.remi.x86_64
php70-php-pecl-geospatial-0.1.0-1.el6.remi.x86_64
php70-php-pecl-hprose-1.6.4-1.el6.remi.x86_64
php70-php-pecl-hrtime-0.5.1-6.el6.remi.x86_64
php70-php-pecl-http-3.0.1-1.el6.remi.x86_64
php70-php-pecl-http-devel-3.0.1-1.el6.remi.x86_64
php70-php-pecl-igbinary-1.2.2-0.1.20151217git2b7c703.el6.remi.x86_64
php70-php-pecl-igbinary-devel-1.2.2-0.1.20151217git2b7c703.el6.remi.x86_64
php70-php-pecl-inotify-2.0.0-1.el6.remi.x86_64
php70-php-pecl-json-post-1.0.1-3.el6.remi.x86_64
php70-php-pecl-libsodium-1.0.6-1.el6.remi.x86_64
php70-php-pecl-lua-2.0.1-1.el6.remi.x86_64
php70-php-pecl-lzf-1.6.5-1.el6.remi.x86_64
php70-php-pecl-mailparse-3.0.1-1.el6.remi.x86_64
php70-php-pecl-memcache-3.0.9-0.2.20151130gitfdbd46b.el6.remi.x86_64
php70-php-pecl-memcached-3.0.0-0.1.20160217git6ace07d.el6.remi.x86_64
php70-php-pecl-mogilefs-0.9.3.1-1.el6.remi.x86_64
php70-php-pecl-msgpack-2.0.1-1.el6.remi.x86_64
php70-php-pecl-msgpack-devel-2.0.1-1.el6.remi.x86_64
php70-php-pecl-mysql-1.0.0-0.9.20151007git294ce3b.el6.remi.x86_64
php70-php-pecl-oauth-2.0.1-1.el6.remi.x86_64
php70-php-pecl-pcs-1.3.1-1.el6.remi.x86_64
php70-php-pecl-pcs-devel-1.3.1-1.el6.remi.x86_64
php70-php-pecl-propro-2.0.0-1.el6.remi.x86_64
php70-php-pecl-propro-devel-2.0.0-1.el6.remi.x86_64
php70-php-pecl-radius-1.4.0-0.1.b1.el6.remi.x86_64
php70-php-pecl-raphf-2.0.0-1.el6.remi.x86_64
php70-php-pecl-raphf-devel-2.0.0-1.el6.remi.x86_64
php70-php-pecl-redis-2.2.8-0.6.20160504gitad3c116.el6.remi.x86_64
php70-php-pecl-rrd-2.0.1-1.el6.remi.x86_64
php70-php-pecl-scrypt-1.4-1.el6.remi.x86_64
php70-php-pecl-seaslog-1.5.3-1.el6.remi.x86_64
php70-php-pecl-selinux-0.4.1-6.el6.remi.x86_64
php70-php-pecl-solr2-2.4.0-1.el6.remi.x86_64
php70-php-pecl-ssdeep-1.0.4-9.el6.remi.x86_64
php70-php-pecl-stats-2.0.1-1.el6.remi.x86_64
php70-php-pecl-swoole-1.8.5-1.el6.remi.x86_64
php70-php-pecl-taint-2.0.1-1.el6.remi.x86_64
php70-php-pecl-trader-0.4.0-2.el6.remi.x86_64
php70-php-pecl-uopz-5.0.1-1.el6.remi.x86_64
php70-php-pecl-uploadprogress-1.0.3.1-11.el6.remi.x86_64
php70-php-pecl-uuid-1.0.4-6.el6.remi.x86_64
php70-php-pecl-weakref-0.3.2-1.el6.remi.x86_64
php70-php-pecl-xattr-1.3.0-1.el6.remi.x86_64
php70-php-pecl-xdebug-2.4.0-1.el6.remi.x86_64
php70-php-pecl-xmldiff-1.1.2-6.el6.remi.x86_64
php70-php-pecl-xmldiff-devel-1.1.2-6.el6.remi.x86_64
php70-php-pecl-xxtea-1.0.11-1.el6.remi.x86_64
php70-php-pecl-yac-2.0.0-1.el6.remi.x86_64
php70-php-pecl-yaconf-1.0.1-1.el6.remi.x86_64
php70-php-pecl-yaconf-devel-1.0.1-1.el6.remi.x86_64
php70-php-pecl-yaf-3.0.2-1.el6.remi.x86_64
php70-php-pecl-yaml-2.0.0-0.6.RC7.el6.remi.x86_64
php70-php-pecl-yar-2.0.0-1.el6.remi.x86_64
php70-php-pecl-yaz-1.2.0-2.el6.remi.x86_64
php70-php-pecl-zip-1.13.2-1.el6.remi.x86_64
php70-php-pecl-zmq-1.1.3-1.el6.remi.x86_64
php70-php-process-7.0.6-3.el6.remi.x86_64
php70-php-xml-7.0.6-3.el6.remi.x86_64
php70-runtime-1.0-4.el6.remi.x86_64
php-cli-7.0.6-3.el6.remi.x86_64
php-common-7.0.6-3.el6.remi.x86_64
php-devel-7.0.6-3.el6.remi.x86_64
php-json-7.0.6-3.el6.remi.x86_64
php-pear-1.10.1-4.el6.remi.noarch
php-process-7.0.6-3.el6.remi.x86_64
php-xml-7.0.6-3.el6.remi.x86_64

【问题讨论】:

  • 在你的类自动加载器中似乎有错误。 “找不到类”与“找不到驱动程序”不同。您是否将所有要求都包含在您的网络脚本中?
  • 我遇到了这个问题。我确实有 mongodb.so,它在 php.ini 上启用,它没有显示在 phpinfo() 上。供应商文件在那里。有什么想法吗?

标签: php mongodb driver php-7 apache2.4


【解决方案1】:

你是如何安装 mongodb 扩展的?

您不必编辑 php.ini。

php70-php-pecl-mongodb RPM 提供了它的配置文件 /etc/opt/remi/php70/php.d/50-mongodb.ini。

“php70 -v”和“php70 -m”的输出是什么?

【讨论】:

  • php70 -v PHP 7.0.6 (cli) (built: Apr 28 2016 21:34:10) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
  • php70 -m(输出太长,但是里面有mongodb扩展)[PHP Modules] ... mogilefs mongodb msgpack ...
  • pecl install mongodb pecl/mongodb is already installed and is the same as the released version 1.1.6 install failed
  • 1/ 安装 php70-php-pecl-mongodb 而不是从源代码构建扩展。 2/ 检查网页中的 phpinfo 以查看您是否真的使用相同的二进制文件。 (发布完整的“rpm -qa php* | sort”我们的输入)
  • mod_php 只能加载一次,因此请检查您是否没有超过 1 个版本,例如php(基础包)+ php70-php(SCL包)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-13
  • 2017-02-16
  • 1970-01-01
  • 1970-01-01
  • 2012-11-21
相关资源
最近更新 更多