Click On Tyler Hall

Originally from Nashville, I'm an engineer working for Yahoo! in Sunnyvale and paying my way with PHP and Cocoa.

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!


Reader Comments


  1. Martin Says:

    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… :-)

  2. Justin Says:

    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

  3. Joel Taylor Says:

    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.

  4. Matt Connolly Says:

    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.

  5. Jason Calleiro Says:

    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!

  6. jjcalleiro Says:

    do you know if i can just move the whole directory to a different location and reference the change in php.ini?

  7. John McKerrell Says:

    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.

  8. Rich Says:

    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.

  9. Installing Symfony Says:

    [...] the terminal and follow the following steps(thanks to this [...]

  10. Keith Says:

    Thanks for the post!

  11. Diana Says:

    When I try “curl http://pear.php.net/go-pear > go-pear.php” I get a permission denied message.

  12. Tyler Hall Says:

    Try running the command with root privileges. “sudo curl http://pear.php.net/go-pear > go-pear.php”

  13. Dharbigt Says:

    You probably mean:

    curl http://pear.php.net/go-pear | sudo php

    Apparently it is broken these days (go-pear, I mean).

  14. Dharbigt Says:

    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)

  15. Savvy Notes Says:

    [...] Navigate to the download in /path/to/your/pear_install/temp/download - (some folks prefer [...]


Leave a Reply