2015-10-01 17:04
浏览 99

在OS X上安装pecl和pear 10.11 El Capitan,macOS 10.12 Sierra,macOS 10.13 High Sierra(<10.13.3)

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 disabling it?

图片转代码服务由CSDN问答提供 功能建议

所以它看起来像新的'系统完整性保护'锁定使梨和pecl成为非 起动机。 有没有人找到一个解决方法而不是禁用它?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

10条回答 默认 最新

  • doulai2573 2016-01-22 19:14

    There's a much easier way — no need to disable SIP or download your own copy:

    sudo php /usr/lib/php/install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin
    解决 无用
    打赏 举报
  • doulei3488 2015-10-02 12:00

    Here's a link to a Macworld article that describes how to enable and disable 'System Integrity Protection.'

    解决 无用
    打赏 举报
  • duan_88598 2015-12-30 20:00

    From this link: With this instructions, you don't need to disable 'System Integrity Protection'

    The following instructions install PEAR and PECL on Mac OS X under /usr/local/. PECL is bundled with PEAR. So this is as simple as installing PEAR on Mac OS X.

    PEAR is PHP’s Package Repository and makes it easy to download and install PHP tools like PHPUnit and XDebug. I specifically recommend these two for every PHP developer.

    Download PEAR

    curl -O
    sudo php -d detect_unicode=0 go-pear.phar

    Configure and Install PEAR

    You should now be at a prompt to configure PEAR.

    1. Type 1 and press return.
    2. Enter:

    3. Type 4 and press return.

    4. Enter:

    5. Press return

    Verify PEAR.

    You should be able to type:

    pear version

    Eventually, if you use any extensions or applications from PEAR, you may need to update PHP’s include path.

    解决 无用
    打赏 举报
  • doujiao2000 2016-04-11 11:16

    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


    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
    chmod +x /usr/local/bin/pear

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

    curl -sL | sudo install -v -m755 /dev/stdin /usr/local/bin/pear
    解决 无用
    打赏 举报
  • doukengsha9472 2016-12-09 23:45

    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
    php -d detect_unicode=0 go-pear.phar
    echo -e "
    export PATH=$HOME/pear/bin:$PATH 
    source ~/.bash_profile
    echo -e "
    include_path = '.:/Users/YOURUSERNAME/pear/share/pear/' 
    " >> /usr/local/etc/php/7.1/php.ini
    git clone ~/tmp/v8js && cd $_
    ./configure CXXFLAGS="-Wno-c++11-narrowing"
    make test
    make install
    sudo apachectl restart
    解决 无用
    打赏 举报
  • douju5062 2018-04-15 11:42

    High Sierra setup:

    • install Brew
    • install PHP with Brew

    There is preinstalled PEAR PACKAGE in


    from there you can run

    pecl install xdebug

    and you should have working PHP binary with Xdebug.

    解决 无用
    打赏 举报
  • duanmie9682 2018-08-07 10:01

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

    brew install php --with-pear
    brew reinstall php --with-pear
    解决 无用
    打赏 举报
  • doujing1967 2018-09-20 19:20

    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
    解决 无用
    打赏 举报
  • dopuzf0898 2019-03-22 22:41

    On Mohave I had to run the following commands - thanks go to

    cd /tmp
    curl -s -O
    sudo php install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin
    解决 无用
    打赏 举报
  • doutan5844 2019-05-15 06:51

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题