How To Install PEAR in Mac OS X Leopard
Wednesday, January 2 2008
Unlike previous version of OS X, Leopard doesn’t come with PHP’s PEAR repository installed by default. Luckily, installing is quick and painless. From a command line:
curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php
Just press enter to select all the default choices except for the installation directory. For that, use /usr/local. (Thanks, Steve.)
Next we need to modify our php.ini file to include the new PEAR files:
sudo cp /etc/php.ini.default /etc/php.ini
Edit /etc/php.ini and change
;include_path = ".:/php/includes"
to read
include_path = ".:/usr/share/pear"
Restart Apache and you’re done!

June 6th, 2008 at 3:47 pm
That's exactly what I've been looking for! Clear and easy. Now, I'm going to check how to use pear to install additionnal packages… :-)
June 16th, 2008 at 12:57 pm
Worked for me, thank you kindly. I chose to use /usr/local for my install location instead of the default /Users/justin, to keep my home folder clean and make the installation available to all users of the system. Kudos on the simple quick instructions
June 20th, 2008 at 4:38 pm
You have to watch the default installation directory - this caught me off guard and didn't work the first time round because it installed in my User directory.
July 30th, 2008 at 6:37 am
My installation defaulted to install in “/Users/matt/pear” which was where I did the curl from.
I had to manually enter the prefix as “/usr/share/pear” during the installation process.
I also didn't need to edit the ini file, as the go-pear.php installer did it automatically for me.
Thanks for the instructions.
October 1st, 2008 at 5:45 pm
if i want to move my installation do i just move the the ones in my home folder to /usr/local/bin and in php.ini let it know?
also how do i put it on my path to call commands without having to type out the full location?
Thanks!
October 1st, 2008 at 5:46 pm
do you know if i can just move the whole directory to a different location and reference the change in php.ini?
October 16th, 2008 at 4:37 am
Thanks for this, very useful :-)
I needed to change the default install location as it was defaulting to the location that I saved go-pear.php (~/Downloads) but apart from that, worked well.
November 5th, 2008 at 1:45 am
Thanks for this, got me off to a good start. However, I had built PHP from source and one weird thing that happens when you do that on a Mac is that the CLI PHP binary is called php.dSYM and not just PHP
After following your guide, I got the following errors:
Richs-MacBook-Pro:src rich$ pear
/usr/local/bin/pear: line 28: /usr/local/php/bin/php: No such file or directory
/usr/local/bin/pear: line 28: exec: /usr/local/php/bin/php: cannot execute: No such file or directory
So, to get Pear up and happy, I just did:
cd /usr/local/php/bin/
sudo ln -s php.dSYM php
I suppose you could do 'sudo mv php.dSYM php' to rename the binary instead of symlinking it.
November 12th, 2008 at 12:53 pm
[...] the terminal and follow the following steps(thanks to this [...]
December 1st, 2008 at 1:24 pm
Thanks for the post!
December 5th, 2008 at 11:56 am
When I try “curl http://pear.php.net/go-pear > go-pear.php” I get a permission denied message.
December 5th, 2008 at 2:56 pm
Try running the command with root privileges. “sudo curl http://pear.php.net/go-pear > go-pear.php”
December 10th, 2008 at 6:23 am
You probably mean:
curl http://pear.php.net/go-pear | sudo php
Apparently it is broken these days (go-pear, I mean).
December 10th, 2008 at 6:26 am
Ope. It looks like it does work (as I had it above) I recommend using /private/tmp for the temp and $prefix/share/PEAR as the PHP code directory.
It won’t work if you are already inside the directory created by the tarball (i.e. you are reading the INSTALL file)
December 18th, 2008 at 8:34 am
[...] Navigate to the download in /path/to/your/pear_install/temp/download - (some folks prefer [...]