skip to Main Content

I’m trying to install PHP 7.1 with Homebrew.

According to the Homebrew site I should type

brew install exolnet/deprecated/[email protected]

and all I get is

configure: error: Please reinstall the iconv library.

Reinstall does not help. Current version libiconv is 1.16.

How fix this error?

4

Answers


  1. Try with the following

    brew install openldap libiconv
    brew tap exolnet/homebrew-deprecated
    brew install [email protected]
    

    For any more details, check this guide

    https://getgrav.org/blog/macos-catalina-apache-multiple-php-versions

    Login or Signup to reply.
  2. I had issues with this:

    dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
      Referenced from: /usr/local/Cellar/[email protected]/7.1.33/bin/php
      Reason: image not found
    

    Solution for me was to first download https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb manually (since installing formula directly renders the error Calling Installation of icu4c from a GitHub commit URL is disabled!) and then:

    $ brew reinstall icu4c.rb
    

    Next, copy the .dylib files from the older icu4c version somewhere temporary:

    $ mkdir ~/temp
    $ cp /usr/local/Cellar/icu4c/64.4/lib/*.dylib ~/temp
    

    Then, reinstall icu4c:

    $ brew reinstall icu4c
    

    Run php 7.1 and copy each necessary .dylib file back to your current icu4c lib folder, accordingly, until php 7.1 renders no errors.

    Login or Signup to reply.
  3. Icu4c reinstallation made me force reinstall PHP8, which broke the purpose for me. So, I have found some new repositories where you don’t need to hassle with this icu4c stuff at all:

    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    brew install shivammathur/php/[email protected]
    

    First, delete all php installations with a command something like brew uninstall "php*" and brew unlink [email protected]

    You may also need to untap other taps. I had to run

    brew untap exolnet/deprecated
    

    to install properly.

    Then, if you want, delete the /usr/local/etc/php folder

    then install one of the packages I’ve linked above.

    Worked Nicely for PHP 7.1:

    ➜  ~ php -v
    PHP 7.1.33 (cli) (built: Dec  1 2020 01:14:43) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies
    

    You can also quickly switch between php versions with a command like:

    brew unlink php && brew link --overwrite --force [email protected]
    

    etc.

    The GitHub repository: https://github.com/shivammathur/homebrew-php

    The source where I found these packages: here.

    Login or Signup to reply.
  4. This worked for me on Big Sur:

    brew tap shivammathur/homebrew-php
    brew install shivammathur/php/[email protected]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search