Flash post: Mac, PHP and “Warning: PHP Startup: Unable to load dynamic library”

I’m on Mac OS X Yosemite (Version 10.10.1) and I’m using PHP 5.5.14.
In a nutshell, every time I write

php -v

on the shell I’ve a list of errors like the following example shows

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

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

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

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

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

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

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

Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_sqlite.dll' - dlopen(/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/php_pdo_sqlite.dll, 9): image not found in Unknown on line 0
PHP 5.5.14 (cli) (built: Jun 28 2014 10:29:43)
Copyright (c) 1997-2014 The PHP Group

This is clearly a problem due to PHP no able to load some libraries previously activated on the php.ini file somewhere, over there.. Over there that I brought it here down to you.

My solution has been execute the following command to locate the php.ini files on my mac

locate php.ini

and the result, in my case was something like

[...]

/usr/local/php5-5.5.14-20140628-105310/lib/php.ini

[...]

So, depending on how you’ve installed your PHP, you’ll have many and different results as different php.ini sources.

I’ve simply commented all the lines loading an extension that returned error, something like the ones where I’ve left a space before the semi column

[...]

; like the following one!
; extension=php_bz2.dll

; extension=php_curl.dll
;extension=php_fileinfo.dll
; extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll

[...]
Advertisements