Installing pecl and pear on OS X 10.11 El Capitan, macOS 10.12 Sierra, macOS 10.13 High Sierra (< 10.13.3)

前端 未结 9 1820
孤城傲影
孤城傲影 2020-12-02 09:38

So it looks like the new \'System Integrity Protection\' lockdown of /usr (among other directories) makes pear and pecl a non-starter. Has anyone found a workaround short of

相关标签:
9条回答
  • 2020-12-02 10:14

    This worked for me as of MacOS Sierra 10.12.1 for upgrading PHP, installing PEAR and V8

    brew tap homebrew/dupes
    brew tap homebrew/versions
    brew tap homebrew/homebrew-php
    
    phpversion="$(php -v | tail -r | tail -n 1 | cut -d " " -f 2 | cut -c 1,3)"
    brew unlink php$phpversion
    
    brew install php71
    brew install autoconf
    
    curl -O  http://pear.php.net/go-pear.phar
    php -d detect_unicode=0 go-pear.phar
    
    echo -e "\nexport PATH=$HOME/pear/bin:$PATH \n"
    
    source ~/.bash_profile
    
    echo -e "\ninclude_path = '.:/Users/YOURUSERNAME/pear/share/pear/' \nextension=v8js.so \n" >> /usr/local/etc/php/7.1/php.ini
    
    git clone https://github.com/phpv8/v8js ~/tmp/v8js && cd $_
    ./configure CXXFLAGS="-Wno-c++11-narrowing"
    make
    make test
    make install
    
    sudo apachectl restart
    
    0 讨论(0)
  • 2020-12-02 10:14

    When brew is used and not linked, use:

    brew install php@5.6
    brew unlink php@5.6
    
    $(brew --prefix php@5.6)/bin/pecl
    $(brew --prefix php@5.6)/bin/pear
    
    0 讨论(0)
  • 2020-12-02 10:15

    For macOS Mojave 10.14.4 just use /local instead of /usr when asked for "Installation base ($prefix)" location.

    0 讨论(0)
  • 2020-12-02 10:17

    Add suffix --with-pear to install pear and pecl
    See example below

    brew install php --with-pear
    brew reinstall php --with-pear
    
    0 讨论(0)
  • 2020-12-02 10:19

    You shouldn't install binaries into system /usr, use /usr/local instead.


    The pecl and pear commands should come along with PHP when installing via Homebrew.

    Here is the example installing PHP with the latest Homebrew:

    brew install php
    

    or the specific version:

    brew install php@7.1
    brew install php@5.6
    

    To find your pecl and pear commands, run:

    find -L "$(brew --prefix php)" -name pecl -o -name pear
    

    or:

    find -L "$(brew --prefix php@7.1)" -name pecl -o -name pear
    

    If you don't have it, consider uninstalling previous PHP version or run reinstall instead.

    You can also try to relink it by:

    brew unlink php@7.1 && brew link php@7.1 --dry-run && brew link --overwrite --force php@7.1
    

    Otherwise, link it manually:

    ln -vs "$(find -L "$(brew --prefix php@7.1)/bin" -name pecl)" /usr/local/bin
    ln -vs "$(find -L "$(brew --prefix php@7.1)/bin" -name pear)" /usr/local/bin
    

    Alternatively download Pear it directly as a Phar package:

    curl -o /usr/local/bin/pear http://pear.php.net/go-pear.phar
    chmod +x /usr/local/bin/pear
    

    or with this following one-liner (will work on Linux, but not on Unix):

    curl -sL http://pear.php.net/go-pear.phar | sudo install -v -m755 /dev/stdin /usr/local/bin/pear
    
    0 讨论(0)
  • 2020-12-02 10:21

    High Sierra setup:

    • install Brew
    • install PHP with Brew

    There is preinstalled PEAR PACKAGE in

    /usr/local/opt/php@<your_version>/bin
    

    from there you can run

    pecl install xdebug
    

    and you should have working PHP binary with Xdebug.

    0 讨论(0)
提交回复
热议问题