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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32893056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:15:55  来源:igfitidea点击:

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

phpmacospearpecl

提问by axlotl

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

因此,似乎/usr(以及其他目录)的新“系统完整性保护”锁定使 pear 和 pecl 成为不可能。有没有人找到禁用它的解决方法?

回答by Paul Schreiber

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

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

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

回答by kenorb

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

您不应该将二进制文件安装到 system 中/usr/usr/local而是使用。



The pecland pearcommands should come along with PHP when installing via Homebrew.

通过Homebrew安装时,peclpear命令应该随 PHP 一起提供。

Here is the example installing PHP with the latest Homebrew:

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

brew install php

or the specific version:

或特定版本:

brew install [email protected]
brew install [email protected]

To find your pecland pearcommands, run:

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

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

or:

或者:

find -L "$(brew --prefix [email protected])" -name pecl -o -name pear

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

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

You can also try to relink it by:

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

brew unlink [email protected] && brew link [email protected] --dry-run && brew link --overwrite --force [email protected]

Otherwise, link it manually:

否则,手动链接它:

ln -vs "$(find -L "$(brew --prefix [email protected])/bin" -name pecl)" /usr/local/bin
ln -vs "$(find -L "$(brew --prefix [email protected])/bin" -name pear)" /usr/local/bin


Alternatively download Pear it directly as a Phar package:

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

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):

或使用以下单行(适用于 Linux,但不适用于 Unix):

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

回答by Sergii Smirnov

From this link: http://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/With this instructions, you don't need to disable 'System Integrity Protection'

从此链接:http: //jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/使用此说明,您无需禁用“系统完整性保护”

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 1and press return.
  2. Enter:

    /usr/local/pear
    
  3. Type 4and 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.

以下说明在 Mac OS X 上的/usr/local/下安装 PEAR 和 PECL 。PECL 与 PEAR 捆绑在一起。所以这就像在 Mac OS X 上安装 PEAR 一样简单。

PEAR 是 PHP 的包存储库,可以轻松下载和安装 PHPUnit 和 XDebug 等 PHP 工具。我特别向每个 PHP 开发人员推荐这两个。

下载梨

curl -O https://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar

配置和安装 PEAR

您现在应该会看到配置 PEAR 的提示。

  1. 键入1并按return
  2. 进入:

    /usr/local/pear
    
  3. 键入4并按return

  4. 进入:

    /usr/local/bin
    
  5. return

验证梨。

您应该能够输入:

pear version

最后,如果您使用来自 PEAR 的任何扩展或应用程序,您可能需要更新 PHP 的包含路径。

回答by Daniel Flippance

On Mohave I had to run the following commands - thanks go to https://tobschall.de/2018/08/07/pear-on-mojave/

在 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

回答by user3890355

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

添加后缀--with-pear安装pear和pecl
见下例

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

回答by davidcondrey

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

从 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

回答by xrep

High Sierra setup:

高山脉设置:

  • install Brew
  • install PHP with Brew
  • 安装 Brew
  • 用 Brew 安装 PHP

There is preinstalled PEAR PACKAGE in

里面有预装的 PEAR PACKAGE

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

from there you can run

从那里你可以跑

pecl install xdebug

and you should have working PHP binary with Xdebug.

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

回答by Mike

When brew is used and not linked, use:

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

brew install [email protected]
brew unlink [email protected]

$(brew --prefix [email protected])/bin/pecl
$(brew --prefix [email protected])/bin/pear

回答by Yasir

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

对于 macOS Mojave 10.14.4,当要求“安装基础($prefix)”位置时,只需使用 /local 而不是 /usr 。