Installing PECL for MAMP

There are a couple of installation instructions for PECL around. But if you use it together with MAMP, installation still doesn’t work (or install things somewhere near the nirvana). This is about how to install it the right way, tie it to MAMP and make your Terminal use the right one from now on:

Your PECL should now be available at /Applications/MAMP/bin/php5/bin/pecl

Use MAMP PECL instead of the wrong one

As you might have an additional “system” pecl in your system server path (which is used by default when you just enter “pecl install” or something alike), make sure you use the mamp one in the terminal.

The easiest way is to adress pecl using the full url any time you call it: Instead of typing

pecl install something

type:

/Applications/MAMP/bin/php5/bin/pecl install something

Pointing to the MAMP PECL from your terminal permanently

This is pretty annoying after a while (and error-prone beyond that!) so tell your terminal which one to use. To do this add an alias in your .bashrc file:

edit the .bashrc of your personal account:

propellermac:testcase achimbode$ sudo edit ~/.bashrc

To the ~/.bashrc file add the following line:

alias pecl=/Applications/MAMP/bin/php5/bin/pecl

When you start a new terminal window, your .bashrc should be run automatically and typing

pecl install something

should now point to the right pecl.

Execute .bashrc automatically

If the .bashrc is not run automatically on shell startup, create a bash_profile.

It’s just about editing the file and add a few lines you find on the page mentioned above. If the file does not exist, create it:

It also colors your terminal prompt red, so you know if it works…
This looks like a lot of work. But actually it’s just editing a few files. And it’s worth while: No more confusion when installing libraries to MAMP! Have fun!