Feb 27 2007
Using MAMP on a Mac
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
becomes:
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: Mac, mamp, OS X, PEAR, PHP, PHPonTrax
[...] March 2007 at 19:30 and filed under Geek, Blog, Mac, OS X, Apple, Open Source, Nerd. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback:Trackback URL. « “Disassemble” [...]
[...] War nicht ganz so einfach. Ich vermute, es liegt daran, dass der MAMP Server nicht auf den regulären Ports läuft (Möglichkeit a) oder im Terminal des Mac PHP4 läuft (eben das mitgelieferte – Möglichkeit b). Bin nach einer Weile diverser Googelei über einen Artikel bei GrinGod gestossen, der folgende Möglichkeiten erklärt (Ich übersetze mal frei, für den Suchenden Google-Nutzer): [...]
Was stuck on getting PEAR packages to work in MAMP. This was very helpful! Thanks!
thanks, very helpful indeed
Thanks for the help – i am installing symfony on my macbook which needs php 5 working on the CLI, i came across the following error:
dyld: NSLinkModule() error
dyld: Library not loaded: /Users/severin/Dev/Projects/MAMP_1.7_src/lib/libltdl.3.dylib
Referenced from: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/mcrypt.so
Reason: image not found
Trace/BPT trap
which can be resolved by running the following command:
export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib:${DYLD_LIBRARY_PATH}
(credit to http://www.karlkatzke.com/symfony-and-mamp-17/)
Justen
Brilliant!!!! Spent days getting here with several false starts. Doing as you suggested got me up and going with MAMP & pear in 10 mins flat.
Well done.
Bill.
solid. I was lost like chick pea in space when it came to getting pear installed. thanks!
If you don’t want to make symbolic links and mess around with your default system installation, an easier way is to just place the path to your MAMP executables in your PATH variable. This can be done in your .bash_profile or .profile file. If you don’t have one already in your home folder, you can just create one. Add the following line to get PEAR working:
export PATH=/Applications/MAMP/bin/php5/bin:$PATH
This prepends the path to the MAMP pear to your path so your shell will automatically look there when you type in a command. Test it out by typing
which pear
The output should look something like this:
/Applications/MAMP/bin/php5/bin/pear
This will also make MAMP php your default php command-line interpreter. Test it out by typing
which php
This should output
/Applications/MAMP/bin/php5/bin/php
[...] I knew that there would be some trick to getting this to work. A quick Google search brought me to this article which taught me just what I needed. [...]