I get this error dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
when switch php verison back to 8.0
.
I can fix it by brew reinstall [email protected]
, but it will happend again when switch verison.
I am using MacOS Big Sur 11.4, but Mojave also got this problem.
My flow
$ php -v
PHP 7.4.19 (cli) (built: May 29 2021 10:41:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies
(base)
$ brew install shivammathur/php/[email protected]
$ php -v
PHP 8.0.6 (cli) (built: May 14 2021 07:18:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies
with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies
(base)
$ brew unlink php && brew link --overwrite --force [email protected]
$ php -v
PHP 7.4.19 (cli) (built: May 29 2021 10:41:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies
(base)
$ brew unlink php && brew link --overwrite --force [email protected]
$ php -v
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
[1] 91532 abort php -v
(base)
Package info
$ brew info [email protected] [email protected] openldap libiconv
[email protected]: stable 7.4.19 (bottled) [keg-only]
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/[email protected]/7.4.19 (494 files, 72.3MB)
Built from source on 2021-05-29 at 10:42:03
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: PHP-3.01
==> Dependencies
Build: httpd ✔, pkg-config ✔
Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl ✔, freetds ✔, gd ✔, gettext ✔, glib ✔, gmp ✔, icu4c ✔, krb5 ✔, libffi ✔, libpq ✔, libsodium ✔, libzip ✔, oniguruma ✔, openldap ✔, [email protected] ✔, pcre2 ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.4/
[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
To have launchd start [email protected] now and restart at login:
brew services start [email protected]
Or, if you don't want/need a background service you can just run:
php-fpm
==> Analytics
install: 34,679 (30 days), 89,314 (90 days), 165,001 (365 days)
install-on-request: 34,481 (30 days), 88,821 (90 days), 164,225 (365 days)
build-error: 0 (30 days)
php: stable 8.0.6 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/php/7.4.12 (495 files, 72.2MB)
Built from source
/usr/local/Cellar/[email protected]/8.0 (494 files, 77.5MB) *
Built from source on 2021-04-09 at 09:59:53
/usr/local/Cellar/php/8.0.6 (500 files, 77.8MB)
Poured from bottle on 2021-05-29 at 17:48:14
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd ✔, pkg-config ✔
Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl ✔, freetds ✔, gd ✔, gettext ✔, glib ✔, gmp ✔, icu4c ✔, krb5 ✔, libffi ✔, libpq ✔, libsodium ✔, libzip ✔, oniguruma ✔, openldap ✔, [email protected] ✔, pcre2 ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/8.0/
To start php:
brew services start php
Or, if you don't want/need a background service you can just run:
/usr/local/opt/php/sbin/php-fpm --nodaemonize
==> Analytics
install: 59,614 (30 days), 153,695 (90 days), 636,046 (365 days)
install-on-request: 58,355 (30 days), 150,786 (90 days), 621,760 (365 days)
build-error: 0 (30 days)
openldap: stable 2.5.4 (bottled) [keg-only]
Open source suite of directory software
https://www.openldap.org/software/
/usr/local/Cellar/openldap/2.5.4 (339 files, 7.0MB)
Poured from bottle on 2021-05-29 at 10:13:28
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openldap.rb
License: OLDAP-2.8
==> Dependencies
Required: [email protected] ✔
==> Caveats
openldap is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have openldap first in your PATH, run:
echo 'export PATH="/usr/local/opt/openldap/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/openldap/sbin:$PATH"' >> ~/.zshrc
For compilers to find openldap you may need to set:
export LDFLAGS="-L/usr/local/opt/openldap/lib"
export CPPFLAGS="-I/usr/local/opt/openldap/include"
For pkg-config to find openldap you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openldap/lib/pkgconfig"
==> Analytics
install: 119,420 (30 days), 336,001 (90 days), 1,036,075 (365 days)
install-on-request: 14,088 (30 days), 46,874 (90 days), 166,063 (365 days)
build-error: 0 (30 days)
libiconv: stable 1.16 (bottled) [keg-only]
Conversion library
https://www.gnu.org/software/libiconv/
/usr/local/Cellar/libiconv/1.16 (30 files, 2.4MB)
Poured from bottle on 2021-05-29 at 15:10:22
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libiconv.rb
License: GPL-3.0
==> Caveats
libiconv is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have libiconv first in your PATH, run:
echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.zshrc
For compilers to find libiconv you may need to set:
export LDFLAGS="-L/usr/local/opt/libiconv/lib"
export CPPFLAGS="-I/usr/local/opt/libiconv/include"
==> Analytics
install: 5,992 (30 days), 14,923 (90 days), 60,385 (365 days)
install-on-request: 4,364 (30 days), 10,383 (90 days), 39,784 (365 days)
build-error: 0 (30 days)
(base)
4
Answers
i had the same issue with [email protected], could solve it with
brew reinstall [email protected]
You’re going to have to run
brew install openldap libiconv
For compilers to find libiconv you may need to set:
Look out and see if openldap is already installed and run
brew upgrade openldap
If you need to have [email protected] first in your PATH, run:
Finally run
brew services start [email protected]
Got this problem after a a complete update to my system.
As of now PHP 7.1 and lower are deprecated from Homebrew (gives warning for 7.2)
This should work any but 7.2 and lower:
I had the same issue when I upgraded my PHP version from 7.3 to 8.0 on macOS Monterey. I resolved the issue with the following steps
Then I exported [email protected] to my PATH variable to have it first in my PATH.
And lastly, I restarted my laptop and everything worked fine.