gpt4 book ai didi

PHP 扩展在 apache 模块中加载,但不在 CLI 中加载

转载 作者:行者123 更新时间:2023-12-02 07:32:06 27 4
gpt4 key购买 nike

我刚刚通过 Brew 在 Mac OSX 10.10.1 上全新安装了 php 5.5(.19),并将 libphp5.so 从 Brew 安装符号链接(symbolic link)到 /usr/libexec/apache2/libphp5.so.

使用 phpinfo() 通过 Apache 启动脚本告诉我加载的 php.ini 文件位于 /usr/local/etc/php/5.5/php.ini.

我已将其添加到 php.ini 的底部:

extension=memcache.so
extension=memcached.so
extension=imagick.so
extension=mongo.so
extension=mcrypt.so

我应该提到的是,这些模块也随 Brew 一起安装。当使用 PHP 作为 Apache 模块时,它们可以毫无问题地加载。但是,当从终端使用 php 时,我收到以下输出:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcache.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcache.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcache.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcache.so, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcached.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcached.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcached.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/memcached.so, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/imagick.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/imagick.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/imagick.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/imagick.so, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mongo.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mongo.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mongo.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mongo.so, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so' - dlopen(/usr/local/Cellar/php55/5.5.19/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so, 9): image not found in Unknown on line 0

运行时:

php --ini

我收到输出:

Configuration File (php.ini) Path: /usr/local/etc/php/5.5
Loaded Configuration File: /usr/local/etc/php/5.5/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.5/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.5/conf.d/ext-memcache.ini,
/usr/local/etc/php/5.5/conf.d/ext-memcached.ini,
/usr/local/etc/php/5.5/conf.d/ext-xdebug.ini

所以我可以看到,加载的配置文件与作为 Apache 模块运行时使用的配置文件相同。

运行:

php -v

给我:

PHP 5.5.19 (cli) (built: Nov 25 2014 11:47:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Xdebug v2.2.6, Copyright (c) 2002-2014, by Derick Rethans

所以我知道它使用了正确的安装(Yosemite 默认 PHP 版本是 5.5.14)。

我似乎无法找出为什么使用 Apache 时扩展加载没有问题,但使用 CLI 时则不然。我该如何摆脱这个警告?

最佳答案

我对 mcrypt 扩展也有类似的问题。

通过从主 php.ini 中删除 extension=mcrypt.so 解决了这个问题,因为该扩展包含在来自 conf.d 的附加文件中> 路径。我认为你可以用同样的方式解决你的问题。只需删除 php.ini 中包含的所有行即可。

祝你好运!

关于PHP 扩展在 apache 模块中加载,但不在 CLI 中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27128281/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com