我最终想要安装PEAR,以便轻松地安装PHPUnit。我想建立一个Mac、Apache、MySQL、PHP、PHPUnit开发环境,以便在本地进行测试。我已经安装好了Apach、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
我将“安装前缀”更改为“/usr/local”,按回车键继续,输入“Y”以安装“PEAR_Frontend_Web-beta、PEAR_Frontend_Gtk2、MDB2”。最终,所有东西都被安装好了。
接下来......
第一次尝试时,我认为php.ini文件中的“include_path”已经被注释掉了,但由于我已经更改了这一行,并且这不是我第一次尝试安装,因此我收到以下消息:
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自动更新我的include路径。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
我按下回车键继续执行,然后收到以下信息:
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 正在尝试创建自己的临时目录进行安装,然后在完成后将其删除。所以我不应该创建这个符号链接,因为在安装完成后会尝试删除临时目录。