mac 10.11 EI capitan 安装pear

刚刚新安装了OS X   EI capitan,10.11这个系统在mac速度提升了很多,刚刚安装好后,pear这个命令是没有的。

pecl: command not found

如何安装pear?

1、下载pear.phar,没有权限在前面加上sudo

curl -O  http://pear.php.net/go-pear.phar

2、安装pear

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

3、会提示安装目录,直接按Enter键发现没有安装权限,就算加上了sudo然并卵。

elow is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/bin
 5. PHP code directory ($php_dir)                 : /usr/share/pear
 6. Documentation directory                       : /usr/docs
 7. Data directory                                : /usr/data
 8. User-modifiable configuration files directory : /usr/cfg
 9. Public Web Files directory                    : /usr/www
10. System manual pages directory                 : /usr/man
11. Tests directory                               : /usr/tests
12. Name of configuration file                    : /private/etc/pear.conf

1-12, 'all' or Enter to continue: 1
(Use $prefix as a shortcut for '/usr', etc.)
Installation base ($prefix) [/usr] : /usr/local/pear

选择1,将默认/usr 换成 /usr/local/pear

4、修改 /etc/php.ini

Would you like to alter php.ini ? [Y/n] : y

5、给pecl命令创建软链接

sudo ln -s /usr/local/pear/bin/pear  /opt/local/bin/pear
sudo ln -s /usr/local/pear/bin/pecl /opt/local/bin/pecl

6、测试

pear version

安装成功!