[TOC] > [安装参考](http://www.mayanlong.com/archives/2018/pear.html) ## 安装 pear 与 peal ``` curl -O https://pear.php.net/go-pear.phar sudo php -d detect_unicode=0 go-pear.phar ``` ``` Below 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 ``` 输入 1,将安装根目录修改为 /usr/local/pear; 输入 4,将命令安装到 /usr/local/bin 目录; 其它选项默认即可,一路回车。 ## pear php 写的工具库 ### 升级或更新源 ``` #如果想升级到最新版本 pear upgrade --force PEAR #更新下仓库 pecl channel-update pecl.php.net ``` ### 安装 ``` pear install DB ``` ## pecl c的依赖包 ### 安装 ``` sudo pecl info redis sudo pecl install redis sudo pecl unisntall redis #也可以使用安装包 wget http://pecl.php.net/get/redis-3.0.0.tgz sudo pecl install redis-3.0.0.tgz ``` ## 常见错误 ### fatal error: ‘php.h’ file not found ` sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include /usr/include` *注意MacOSX10.10.sdk修改为自己系统的版本号* ### pcre.h 找不到 `brew install pcre`