How to install PEAR on Mac OS X Leopard
Since Mac OS X Leopard isn't shipped with PEAR anymore, we have to install it by ourselves. Fortunately it's a very easy operation that won't take much of your time away. So, enough talking and let's put that useful tool on feet! All you need is an Internet connection (duh!) and you Terminal app (hopefully on full screen).
[geshifilter-code language="bash"]
nuno@mac ~ $ curl -O http://pear.php.net/go-pear
nuno@mac ~ $ mv go-pear go-pear.php
nuno@mac ~ $ sudo php -q go-pear.php
[/geshifilter-code]
First we will grab the installation script from the PEAR official page, then we rename it to php extension file (this step isn't necessary at all, I just like to keep my files organised for a better tracking). Finally, we execute the script ("Command-line PHP scripts almost always use the -q flag, which prevents PHP from printing HTTP response headers at the beginning of its output [...]." in O'Reilly PHP Cookbook).
A little CLI configuration wizard will appear. Almost everything should be accepted by default, except the installation prefix which must be /usr/local. The main reason for that is that we are proceeding to a local installation. Because it's beyond the purpose of this article, you can read further here, here and here. So, there's how your settings should look:
[geshifilter-code]
1. Installation prefix ($prefix) : /usr/local
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
[/geshifilter-code]
We are almost done, we just have to make a little modification on php.ini configuration file. If you use built-in PHP installation, that file lays under /private/etc/php.ini. If you use MAMP or a similar, it should be located at /Applications/MAMP/conf/php5/php.ini. Open it with you favourite editor (Vi, Emacs or so) and search for the following property:
[geshifilter-code language="apache"]
include_path = ".:/some/path"
[/geshifilter-code]
If the go-pear installation didn't added a line like
[geshifilter-code language="apache"]
;***** Added by go-pear
include_path=".:/usr/local/PEAR"
;*****
[/geshifilter-code]
please, do. However you should be aware that that variable isn't already set on the file. If so, just add the path like that:
[geshifilter-code language="apache"]
include_path = ".:/some/path:/some/other/path:/usr/local/PEAR"
[/geshifilter-code]
Now just restart your Apache and that's it! You have a nice pear into an Apple. Enjoy your fruit salad! 


















Comments
Post new comment