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).
Currently the path is pointing to the wrong php bin
“/usr/bin/php”, to change this we need to modify a variable. 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.5 of PHP, but you can choose from whichever versions are available to you. .
$ echo "export PATH=/Applications/MAMP/bin/php/php5.3.5/bin:$PATH" >> ~/.profile
I assume you’ve installed MAMP already, first we will download the MAMP Server components and libraries zip file (this will take some time :F).
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.
In this example I use php5.3.5, check which PHP version you are running on your MAMP installation.
// we will create a new directory /include and /php $ mkdir /Applications/MAMP/bin/php/php5.3.5/include $ mkdir /Applications/MAMP/bin/php/php5.3.5/include/php // moving everything from the download package to the directory php $ mv ~/Downloads/MAMP_components_2.0.2/php-5.3.5 /Applications/MAMP/bin/php/php5.3.5/include/php // change to the php directory $ cd /Applications/MAMP/bin/php/php5.3.5/include/php // configure $ ./configure
Next we need to tell the perl and pear script where the php.ini is located, in my case this is “/Applications/MAMP/config/php5.3/php.ini”. You can find the location of your php.ini file on the php info page.
pear config-set php_ini /Applications/MAMP/config/php5.3/php.ini pecl config-set php_ini /Applications/MAMP/config/php5.3/php.ini
All being well, you should now be able to install PECL extensions.
$ sudo CFLAGS="-arch i386" pecl install svn
or you can do it manually
$ cd /Applications/MAMP/bin/php5.3/include/php-5.3.5/ext/ $ pecl download svn $ tar -xf svn-1.0.2.tgz $ mkdir svn $ rsync -xav svn-1.0.2/ svn/ $ rm -r svn-1.0.2/ $ cd svn/ $ /Applications/MAMP/bin/php5.3/bin/phpize $ MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" ./configure --with-imap=/usr/local/imap-2007 --with-kerberos --with-imap-ssl=/usr/ $ make // this directory can change from installation, so check if it's the correct one $ sudo cp modules/svn.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/
Next go to the main window of MAMP click File -> Edit Template and choose the correct php.ini you want to edit, add a new line in the extension section: extension=svn. Restart MAMP and our module will apear on the PHP info page.