With all the LAMP stacks in the world, its hard to imagine we need yet another howto blog post. But I did have some trouble getting things running smoothly on my Mac and I’d like to share my experiences with you, the gentle reader. Living-e bundles Apache, MySQL and PHP stack for the Mac called MAMP. It’s made to run out of the box and it certainly lived up to its promise.
And, yes, before you ask – I really tried to go the purist route. I installed MySQL after perusing the “incredibly helpful and updated” Apple documentation on the subject (circa 2005 where they even spend a paragraph discussing MySQL drawbacks). But what defeated me in the end was trying to configure such oddball php plugins like pdo_mysql, GD2 and mbstring. I wasted almost a day of my life in the process. Abandon all hope, ye who enter here!
MAMP, on the other hand, is literally drag-and-drop. Voila! Full PDO, GD2 and mbstring support. It has an active and thriving community forum where a lot of the answers to questions you don’t even have yet can be found.
Dealing with a non-standard MySQL install
Since you won’t be using a “standard” MySQL database (living in /etc/mysql) some common GUI tools like Administrator and Query Browser won’t work completely out of the box. I found the simplest way to get the basic controls is to connect via Socket (aka file):
If your database is bigger than 10MB don’t bother trying to import it with phpMyAdmin. I wasted time trying to bump up the various upload parameters in php.ini to no avail. Just go straight for the jugular:
dan@test:~$ mysqldump -uwork -p workdb > workdatabase.sql
dan@localhost:~$ scp test:~/workdatabase.sql .
dan@localhost:~$ /Applications/MAMP/Library/bin/mysql -uwork-p workdb < workdatabase.sql
Ugly Installation of PHP Libraries
PDO MySQL support came right out of the box, along with GD2 and mbstring. Wow, I’ve already saved more than half a day in about half-an-hour! Setting up stem support however … ouch. I had to manually copy the PHP library headers from Mac OS X codebase in order to get the PECL build working for stem. Note: you’ll need to install Xcode tools before getting a hold of these header files.
cp -Rf /Developer/SDKs/MacOSX10.5.sdk/usr/include/php /Application/MAMP/bin/php5/include/
/Applications/MAMP/bin/php5/bin/pecl install stem
Build process completed successfully
install ok: channel://pecl.php.net/stem-1.5.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=stem.so" to php.ini
Ok, so far, so good. Here’s where another wrench got thrown into the picture though. The stem.so library was built in the extension directory ‘no-debug-non-zts-20060613’ whereas MAMP looks by default into the directory ‘no-debug-non-zts-20050922’. Let’s make our life a bit easier and move the stem library there while enabling it for our application:
cp /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/stem.so /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/
vi /Applications/MAMP/conf/php5/php.ini :
Restarting Apache gives us the following:
Now we’re talking! The entire web application runs on my localhost and it’s time to start developing. Stay tuned when I show you next week how to get Xdebug profiling tool running and integrated with Eclipse!
3 thoughts on “Configuring MAMP for Development”
Great post, thanks. I’ve been wrestling with installing stem for about two days but it is still not working… I copied the libraries just like you did, got my pecl within MAMP working, and the stem.so was even directly installed in /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922. However when restarting MAMP, I get the message Unable to load dynamic library ‘/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/stem.so, as if the library just wasn’t there…. do you have any idea what’s going on?
double check the extension directory according to MAMP’s php … something like:
danackerson@dansMB ~$ /Applications/MAMP/bin/php -i | grep extension_dir
extension_dir => /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922
Besides that, are you sure you added the extension in the php.ini (and restarted the MAMP Apache proc)?
Dan, thanks for the answer.
The extension directory is the correct one, and I definitely included the extension=stem.so line in the php.ini file (if I remove this line from the php.ini, Apache does not even try to load it). I also tried to change the extension directory to a directory where I installed the stem.so library manually, but no luck there either.
I suspect that the library itself is corrupted, though I don’t see why it would be since everything went fine during the compilation. Is there a way to just check whether the library is corrupted without loading it into apache?