PHP extensions loading in apache module, but not in CLI

不想你离开。 提交于 2020-01-04 06:26:11

问题


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.

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.

I've added this to the bottom of the php.ini:

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

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

When running:

php --ini

I receive the output:

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.

Running:

php -v

gives me:

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

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

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?


回答1:


I has the similar issue with mcrypt extension.

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.

Good luck!



来源:https://stackoverflow.com/questions/27128281/php-extensions-loading-in-apache-module-but-not-in-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!