我最终尝试安装 PEAR,以便可以轻松安装 PHPUnit。我想建立一个 Mac、Apache、MySQL、PHP、PHPUnit 开发环境,这样我就可以在本地进行测试。我已经有 Apache、MySQL 和 PHP 工作。现在我只需要 PHPUnit,这意味着我需要 PEAR 来安装它。
我已经到处搜索了,关于如何在 Mac OS X 10.5 上安装 PEAR 的“教程”有一些变体。但是,我似乎无法让它们中的任何一个工作!有没有人在这方面取得成功?我并不完全相信我已按应有的方式设置了所有内容,因此,如果您可以包含“默认” Mac OS X 10.5 包含路径,或者对所有内容的位置进行简单说明,我将不胜感激。
按照本教程,我执行以下操作:
curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php
我按回车键,直到进入包含 7 个包含路径的列表:
1. Installation prefix ($prefix) : /Users/andrew
2. Temporary files directory : $prefix/temp
3. Binaries directory : $prefix/bin
4. PHP code directory ($php_dir) : $prefix/PEAR
5. Documentation base directory : $php_dir/docs
6. Data base directory : $php_dir/data
7. Tests base directory : $php_dir/tests
我改成Installation prefix
,/usr/local
按回车继续,输入Y
也安装PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2
。最终,一切都安装好了。
下一个...
在第一次尝试时,我认为include_path
php.ini 文件被注释掉了,但由于我已经更改了这一行,而且这不是我第一次尝试安装,我收到以下消息:
WARNING! The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
</usr/local/PEAR>
If the specified directory is also not in the include_path used by
your scripts, you will have problems getting any PEAR packages working.
Would you like to alter php.ini </private/etc/php.ini>? [Y/n] :
我输入Y
并让 pear 自动更新我的包含路径:
php.ini </private/etc/php.ini> include_path updated.
Current include path : .:/usr/share/pear
Configured directory : /usr/local/PEAR
Currently used php.ini (guess) : /private/etc/php.ini
我按 Enter 继续,并收到以下消息:
The 'pear' command is now at your service at /usr/local/bin/pear
** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/local/bin/pear' until you have added
** '/usr/local/bin' to your PATH environment variable.
Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.
For more information about PEAR, see:
http://pear.php.net/faq.php
http://pear.php.net/manual/
Thanks for using go-pear!
PHP Warning: rmdir(/usr/local/temp): Not a directory in /Users/andrew/go-pear.php on line 1237
Warning: rmdir(/usr/local/temp): Not a directory in /Users/andrew/go-pear.php on line 1237
更新:我想我知道为什么会出现最后两个警告。以前,我尝试通过创建指向 /tmp 的符号链接来解决临时目录问题,但如果我理解正确,PEAR 正在尝试创建自己的临时目录以进行安装,然后它将在完成后将其删除。所以我不应该创建这个符号链接,因为它会在安装完成后尝试删除临时目录。