4
sudo php -d detect_unicode=0 go-pear.phar

Unable to create PHP code directory ($php_dir) /usr/share/pear.

Do I need to change permissions on /usr/share? Current permissions are drwxr-xr-x

JAstuccio
  • 1,502
  • 2
  • 18
  • 20
  • Possible duplicate of [Installing pecl and pear on OS X 10.11 El Capitan, macOS 10.12 Sierra, macOS 10.13 High Sierra (< 10.13.3)](https://stackoverflow.com/questions/32893056/installing-pecl-and-pear-on-os-x-10-11-el-capitan-macos-10-12-sierra-macos-10) – E_net4 Jul 30 '19 at 19:11

2 Answers2

5

The /usr folder is protected. You can disable SIP, but this is not the best option.

You can select 1 for the "Installation base" and change the directory to /usr/local

Then it will apply to all other addresses.

Take a look on this other question https://apple.stackexchange.com/questions/237778/cant-write-to-usr-even-with-sudo

  • I got this: `PHP Startup: Unable to load dynamic library 'grpc.so' (tried: /usr/lib/php/extensions/no-debug-non-zts-20180731/grpc.so (dlopen(/usr/lib/php/extensions/no-debug-non-zts-20180731/grpc.so, 0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-non-zts-20180731/grpc.so), /usr/lib/php/extensions/no-debug-non-zts-20180731/grpc.so.so (dlopen(/usr/lib/php/extensions/no-debug-non-zts-20180731/grpc.so.so, 0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-non-zts-20180731/grpc.so.so))` – glinda93 Mar 25 '21 at 15:16
-2

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 http://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.

Type 1 and press return.
Enter: /usr/local/pear

Type 4 and press return.
Enter: /usr/local/bin

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.
Serhii Smirnov
  • 1,338
  • 1
  • 16
  • 24