Installing Apache-PHP-Mysql on an USB flash drive on Mac23 juillet 2007 - Roberto

Why installing Apache-PHP-Mysql on an USB flash drive ?

I’m a lucky guy. I own several Macs, at home, office and a MacBook (see here). I am developping teepsy and I was looking for an easy solution that would let me install Apache, PHP and MySQL, and my scripts, on various computers, and which allows me to continue my work on my scripts, without thinking about the machine’s config.

I was looking for a solution like WAMP, under Windows, which contains all that is necessary for a PHP developer : a server (Apache), PHP and MySQL. On Macs, this solution is called MAMP.

Some people may say that Apache and PHP are already installed in Mac OS X. It’s true, but I don’t like it for two reasons: 1) MySQL does not come with, and frankly it’s not very easy to install. 2) If, like me, a nonstandard configuration is necessary (extensions, recent PHP version, …), it is necessary to install the changes on each machines.

In love the way APPLE makes the software’s installation easy : Drag-Drop = Installed. I decided to find a solution which would contain all the above mentioned components, but also the scripts of my applications.

Use MAMP

MAMP is very interesting, because you just have to drag the MAMP folder into the “Applications” one, and it’s done. At the end of the day, you just copy the folder on your USB flash drive, and all your work holds in that device. You just have to copy it in the MacBook or at home, to see your scripts working again.

But, I’m lazy, and all these copies annoy me. Why not work directly on the flash drive? If you don’t care about speed performances (which can be optimized later in the development), this solution lets you work on scripts and test them without installing anything on the “host” machine.

The problem, is that the “MAMP” folder must imperatively be installed in the “Applications” one. There is no option in the MAMP preferences which allows you to install it elsewhere.

Installing MAMP on a Disk Image

I will show you, step by step, how to install the server on a Disk Image, and how to make believe MAMP that its files are in the “Applications” folder.

We will create a new Disk Image (with the Disk Utility), which will contain all MAMP files and our scripts. This image is named here “MAMP-traveller” and save it on your USB flash drive and mount-it.

Then, download MAMP from the official site.

Do not pay attention to the “MAMP PRO” folder, only “MAMP” will be used here (and is free). Instead of dragging the “MAMP” folder in “Applications”, we will drag it into “MAMP-traveller”. We rename then this folder: “MAMP-files”.

Change MAMP location : create alias

Then, we create an alias for “MAMP” in the “Applications” folder. If you use the right button on the “MAMP-files” directory, and the choose “Create an alias”, you’ll get an alias to place in the “Applications” folder. Normally, MAMP should be blind and don’t see the trick. But in fact, it does. The alias created that way is not understood by MAMP.

So we’ll create the aliases with the UNIX command “ln”, in the terminal. Open the terminal, and type the following line:
ln -s /Volumes/MAMP-traveller/MAMP-files /Applications/MAMP

This creates an alias “MAMP” in “Applications” which points to “MAMP-files”.

Now, you can launch MAMP.

It works perfectly.

Last details

A small trick for later, create two new aliases as follows:
ln -s /Volumes/MAMP-traveller/MAMP-files /Volumes/MAMP-traveller/MAMP
and
/Applications/ /Volumes/MAMP-traveller/Applications

These two aliases are created in the root folder of “MAMP-traveller”. They’ll be very useful when you will use all this on another computer.

Now customize the MAMP configuration, place your scripts in the “MAMP-traveller/MAMP-files/htdocs” folder, and save all.

Once that you finished your day, close MAMP, to unmount “MAMP-traveller”, and eject your USB flash drive.

When you insert that key in another Mac, mount “MAMP-traveller”. The only thing to do is to drag the alias “MAMP” on “Applications”. Then, launch MAMP, and it works!!

  1. How about doing all this, and then inserting the USB drive into a PC to show a client who uses PC’s?. How will it work?

  2. It won’t. This just works on Mac, because MAMP is a Mac application. But you should be able to do the same thing using WAMP.

  3. Thanks, I’m in an identical situation to you and this is exactly what I was looking. Cheers for taking the time to post this.

  4. Installing Version 1.7.1 Full on an intel MBPro can’t get it to work, Help please.
    Thanks

  5. MBPRo running 10.5.4

  6. Tks!!
    You save my day!!

  7. Hi there, thanks a million for sharing great information. One question… did you have any problem using MAMP and mail? I haven’t been able to get it to work correctly. Also, does this configuration work with MAMP Pro?

    Best, monte

  8. Thank you! Thank you! I can now edit my wordpress site locally from my flash drive!

  9. Hi,

    thanks for the GREAT solution… ;-)

    BUT:
    What, if i have a MAMP-installation on my iMac as well and want to have the USB-solution as a additional feature?

    There is another “MAMP” dir necessary (but impossible), or how can i solve that problem?

  10. Is it possible to do this with MAMP PRO?
    My root partition does not have much room so i’m trying to install MAMP & MAMP PRO on a larger partition with a symbolic link at /Applications/MAMP pointing to /Volumes/USBdrive/Applications/MAMP.

    However, i get a 403 error when trying to browse the site. And apache log shows “Symbolic link not allowed: /Applications/MAMP”

    I have configured httpd.conf:

    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

    Any help would be really appreciated.

  11. Works like a charm! Good job and thanks! There’s some performance issues with putting it on a USB disk so I tried it on a WD Passport (External Harddrive) and it works great.

  12. Hi

    found your site after searching for ages. Will this technique work for mamp pro?

    great tutorial

  13. I tried to do my best, but it seems that this solution doesn’t not work with MAMP Pro…

  14. Thanks for the tutorial, just what I needed for development purposes.

  15. Is it possible to have one usb drive that can run both WAMP and MAMP with both pointing to the same htdcocs so that you can edit the site on Mac or PC

  16. Hi there. I’m stuck at this step: “Instead of dragging the “MAMP” folder in “Applications”, we will drag it into “MAMP-traveller”. We rename then this folder: “MAMP-files”.”

    When I attempt to do this on both a 4 gig and 8 gig usb drive, I get the following message:

    The item “MAMP” can’t be copied because there isn’t enough free space.

    Any help anyone?

Laissez un commentaire !

  • Catégories