Feb 27 2007

Using MAMP on a Mac

Published by at 12:16 pm under PHP,Programming

This is an old article and the information contained within it may be out of date, not reflect my current views and/or contain broken links. If you feel this article is still valid and requires updating, you can use the contact form to let me know. However, I make no guarantee that it will get updated.

I’ve had MAMP installed on my Mac since the day I got it. Yeah, yeah, laugh if you want but I find *AMP a fast platform for developing on and have used since my first year at Uni.

Anyhow, installing MAMP and getting it running was incredibly easy. In fact the installer did everything (so long as you use the default directories). For this reason I’m not going to be covering the basic installation. What I am going to cover is getting the MAMP installation setup as the default installation of PHP as used on the command line. I’ll also cover getting PEAR working on the command line and even as far as setting up Trax for use on the command line. For the article I’m going to assume you’re using the MAMP default settings with PHP5.

Once you have installed MAMP on your Mac you can use it like you would on a webserver, you just need to point you browser at http://localhost:8080. This is all good until you need to use PHP on the command line. If you type the following on the command line:

php -v

You’ll probably find that the output indicates that the command line version of PHP is 4.x and not PHP 5.x like you want it to be. The fix for this is quite simple, you just need to run the follow commands on the command line:

sudo mv /usr/bin/php /usr/bin/php-old
sudo ln -s /Applications/MAMP/bin/php5/bin/php /usr/bin/php

This will make the MAMP installed version of PHP the default on the command line. If you want to do the same for the MAMP installed version of PEAR then you need to do the following:

sudo mv /usr/bin/pear /usr/bin/pear-old
sudo ln -s /Applications/MAMP/bin/php5/bin/pear /usr/bin/pear

Now you can go ahead and use PHP and PEAR on the command line like all the installation guides and tutorials show you.

FInally, if you are installing PHPonTrax here are a few things that will make your life easier. The documents tell you to use the trax command. If you try this, however, you’ll probably get a message that the application trax cannot be found. To make trax available run the following command:

sudo ln -s /Applications/MAMP/bin/php5/bin/trax /usr/bin/trax
Also, when the trax documentation tells you to run php scripts on the command line always prepend it with php for example:

./generate.php model


php ./generate.php model

I hope this help alleviate some of your problems. If not, pour yourself a coffee, head over to http://www.askaninja.com/ and watch a couple of episodes, then drop me a comment asking for help. I may not know all the answers but I should be able to point you in the right direction.

Technorati Tags: , , , , ,

9 responses so far