PHP扩展加载到apache模块中,但不在CLI中加载 [英] PHP extensions loading in apache module, but not in CLI

查看:93
本文介绍了PHP扩展加载到apache模块中,但不在CLI中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've just performed a fresh install of php 5.5(.19) on Mac OSX 10.10.1 through Brew and symlinked libphp5.so from the Brew install to /usr/libexec/apache2/libphp5.so.

使用 phpinfo()告诉我加载的 php.ini 文件位于 / usr / local / etc / php /5.5/php.ini

Firing up a script through Apache with phpinfo() tells me that the loaded php.ini file is located at /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时,会收到以下输出:

I should mention that these modules are installed with Brew also. They load without issue when using PHP as an Apache module. However, when using php from the terminal, I receive the following output:

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

所以我看到加载的配置文件与

So I can see, that the loaded configuration file is the same as the one used when running as an Apache module.

运行:

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)。

So I know it's using the correct installation (Yosemite default PHP version is 5.5.14).

我似乎无法找出为什么使用Apache而不是使用CLI加载扩展时不会出现问题的原因。如何摆脱此警告?

I can't seem to find out why the extensions load without issue when using Apache, but not when using CLI. How do I get rid of this warning?

推荐答案

我对 mcrypt 扩展名。

通过从主 php.ini中删除 extension = mcrypt.so 来解决此问题,因为该扩展名包含在 conf.d 路径中的其他文件中。我认为您可以在相同模式下解决您的问题。只需删除 php.ini 中包含的所有行。

Solved it by removing extension=mcrypt.so from main php.ini because the extension was included in additional file, from conf.d path. I think you can solve your problem it in same mode. Just remove all rows that you are included in your php.ini.

祝你好运!

这篇关于PHP扩展加载到apache模块中,但不在CLI中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆