Assuming you have php installed and working already. And I am using osx 10.6.

Obtaining the installation package/script.

curl http://pear.php.net/go-pear.phar > go-pear.phar

Then run it

sudo php go-pear.phar

It will then ask you for the path settings. I suggest installing pear at the /usr/local dir, but this is really your preference. In my case, I entered 1, then changed the $prefix to “/usr/local/pear”. The paths below #1 should automatically change accordingly. Then enter to install.

Now, you will need to set your env path variable to point to this pear dir. Open up your ~/.bash_profile, then enter the following line.

PATH=/usr/local/pear/bin:$PATH

Then open up a new shell and run “which pear”. If everything is fine, you will get “/usr/local/pear/bin/pear”.

You probably want to change your php.ini file to include the pear dir as well.

include_path = ".:/usr/local/pear/share/pear:/php/includes"

To install a pear package, say Console_Getopt, just do the following:

sudo pear install Console_Getopt

I am using sudo here because I installed my pear at /usr/local. If you installed pear at your local dir you can take out sudo.

If you used sudo to install pear at your local dir, the /tmp/pear/install dir may be unwritable coz it’s owned by root. You can simply remove that by “sudo rm -rf /tmp/pear”. Then do your “pear install” again as a local user.