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!