简体   繁体   中英

How to overcome the “dyld: Library not loaded:” error when installing PHP on Mac?

I'm trying to install the latest version of PHP on my Mac. I tried this

brew install php72 --force

and then wanted to check the version, but got this error

localhost:regagents davea$ php --version
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /usr/local/Cellar/php72/7.2.1_12/bin/php
  Reason: image not found
Abort trap: 6

so I figured I could re-install readline, so I think I did ...

 localhost:regagents davea$ brew reinstall readline
==> Reinstalling readline 
==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.0.high_sierra.bottle.tar.gz
Already downloaded: /Users/davea/Library/Caches/Homebrew/downloads/c0566e677ba9f92c270590e2d8132f95668817a7817d2ee47711ff3c2ff045d6--readline-8.0.0.high_sierra.bottle.tar.gz
==> Pouring readline-8.0.0.high_sierra.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/readline/8.0.0: 48 files, 1.5MB

but then running "php -version" gives me the same error. What gives? How do I install and run php on my Mac?

Your older version of php is linked against readline 7. You have readline 8. Update php: the latest version of the php72 package in homebrew is 7.2.17_1.

brew update
brew upgrade php72

php 7.3.4 is available from the php package. To install the latest version of php:

brew install php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM