MAMP is a very handy server environment for web stuff, here’s what i do to set it up:
use my ‘Sites’ folder as document root - basically keep it out of the MAMP application so when i upgrade mamp or migrate my user folder it keeps my stuff
Change the apache port to 80 - that way my urls look normal and don’t have the colon/port number after them
read more about all that here:
I like to make virtual hosts for all my development websites. I call them sitename.dev, rather than their online equivalent sitename.com for instance. This makes lots of things work better (i.e. the same document root for your code).
edit your hosts file here: /etc/hosts
I install the terminal command for TextMate and Sublime, so currently I type this in terminal to open that file:
add a line to this file that looks like this:
The open this file within the MAMP application:
Find this line (use the find tool - its around line 584 on mine, but this sort of thing changes):
# Virtual hosts
remove the hash before ‘Include’ so it looks like this:
# Virtual hosts
Then go to this file:
There are various examples there, but the minimum you need (and i never use any more than this) is below. You must redefine ‘localhost’ to be the same folder you set up as the MAMP document root above. Then you can define as many virtual hosts as you like with the second bit:
In the above example yourusername is your user folder, sitefolder is the folder you’ve got your site in, yoursite.dev is what you defined in the /etc/hosts file.
Now stop, then start the MAMP server and you should be able to go to yoursite.dev and it will work.
A hand trick to find the exact location of a file/folder in the way that MAMP and many other bits of software expect to see it is to grab the file and drag it into a terminal window - you can then copy this path, much quicker than typing it.