Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

macos

pear

pecl

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?

like image 226
axlotl Avatar asked Oct 01 '15 17:10

axlotl


3 Answers

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
like image 153
Paul Schreiber Avatar answered Nov 16 '22 11:11

Paul Schreiber


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 [email protected]
brew install [email protected]

To find your pecl and pear commands, run:

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 reinstall instead.

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:

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
like image 41
kenorb Avatar answered Nov 16 '22 11:11

kenorb


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'

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.

like image 51
Serhii Smirnov Avatar answered Nov 16 '22 12:11

Serhii Smirnov