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

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

所以看起来新的 'System Integrity Protection' lockdown of /usr(在其他目录中)使 pear 和 pecl 成为一个非启动器。有没有人找到禁用它的解决方法?

从此link:http://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/使用此说明,您无需禁用'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 https://pear.php.net/go-pear.phar
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:

    /usr/local/pear
    
  3. Type 4 and press return.

  4. Enter:

    /usr/local/bin
    
  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.

有一种更简单的方法 — 无需禁用 SIP 或下载您自己的副本:

sudo php /usr/lib/php/install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin

您不应将二进制文件安装到系统 /usr 中,而是使用 /usr/local


通过 Homebrew 安装时,peclpear 命令应该与 PHP 一起出现。

这是使用最新的 Homebrew 安装 PHP 的示例:

brew install php

或具体版本:

brew install php@7.1
brew install php@5.6

要查找您的 peclpear 命令,运行:

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

或:

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

如果没有,请考虑卸载以前的 PHP 版本或 运行 reinstall

您也可以通过以下方式尝试重新link它:

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

Otherwise,link手动:

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

或者直接将 Pear 作为 Phar 包下载:

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

或使用以下单行代码(将在 Linux 上工作,但不适用于 Unix):

curl -sL http://pear.php.net/go-pear.phar | sudo install -v -m755 /dev/stdin /usr/local/bin/pear

从 MacOS Sierra 10.12.1 开始,这对我有用,可以升级 PHP,安装 PEAR 和 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

High Sierra 设置:

  • 安装 Brew
  • 使用 Brew 安装 PHP

中预装了PEAR PACKAGE
/usr/local/opt/php@<your_version>/bin

从那里你可以运行

pecl install xdebug

并且您应该可以使用 PHP Xdebug 二进制文件。

添加后缀 --with-pear 以安装 pear 和 pecl
请参阅下面的示例

brew install php --with-pear
brew reinstall php --with-pear

当使用 brew 且未链接时,使用:

brew install php@5.6
brew unlink php@5.6

$(brew --prefix php@5.6)/bin/pecl
$(brew --prefix php@5.6)/bin/pear

在 Mohave 上,我必须 运行 以下命令 - 感谢转至 https://tobschall.de/2018/08/07/pear-on-mojave/

cd /tmp
curl -s -O https://pear.php.net/install-pear-nozlib.phar
sudo php install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin

对于 macOS Mojave 10.14.4,当询问 [​​=12=] 位置时,只需使用 /local 而不是 /usr。

大苏尔:

brew install php

brew services start php