18. Oktober 2015

Installing PHP PEAR and PECL extensions on MAMP for Mac OS X


Configure command work for me when I chose this option:

./configure –without-iconv

Otherwise I am getting the error:

‚zend_config.h‘ file not found


Original article


MAMP is an easy to install set of tools for that provides a great local development environment for Mac users (Mac Apache MySQL PHP). OS X does ship with its own built in versions of these tools, but MAMP adds lots of goodies. The newest version of MAMP includes a graphical configuration tool, a choice of PHP versions, web-based tools for administering your databases, and a variety of useful PHP extensions.

Unfortunately, MAMP doesn’t include everything. If you’re developing a site that needs additional PHP extensions like the Memcached library or exotic database drivers, you’ll need to use the PEAR and PECL tools to build and install them. PECL (PHP Extension Community Library) and PEAR (PHP Extension and Application Repository) both provide access to a large pool of useful PHP add-ons, but using them with MAMP requires you to do a bit of extra configuration. In this article, you’ll learn how to get them running on the latest version of MAMP (2.x).


The usual method for installing PEAR and PECL components is via the command line. Here is an example for installing PHPUnit.

Easy! Unfortunately, if we try this after we’ve installed MAMP we’ll get an error as the „pear“ command can’t be found and running „php“ will point us to OS X’s default version.


To rectify this we need to add PHP’s binaries to our path. The path is an environment variable that denotes which directories to look for commands in. The path can be modified by editing the „.profile“ file under your home directory. I’ve used version 5.3.6 of PHP, but you can choose from whichever versions are available to you.

Now you can either restart your terminal session or run the following from your home directory to read in the new path variable.

You should now have the correct binaries on your path and can check this by running the „which“ command again.

If this doesn’t work make sure that your PHP binaries have execute permissions, an easy way to tell is by running


Hurray! Good times.


For PECL to work we need to prepare the build environment for extensions by making the PHP source available. Download the MAMP Server components and libraries zip file and make yourself a cup of tea whilst you wait. Perhaps have a biscuit as well, I recommend the classic custard cream. You’ll also need to have Xcode installed to get Autotools.

Once it’s downloaded, find the zip file corresponding to your version of PHP, extract it into a new directory in your PHP installation and run the configure script.

***./configure –without-iconv***

All being well, you should now be able to install PECL extensions.

You can now have some upload progress goodness by editing your php.ini file (in this case /Applications/MAMP/bin/php/php5.3.6/conf/php.ini) and restarting the MAMP servers.