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!!

Laissez un commentaire !

  • Catégories