MAMP is Mac Apache, MySQL and PHP, in one convenient package.
As of the time of this writing, MAMP 1.4.1 (the most recent stable release) currently contains the following components:
That's pretty impressive for a basically one-click install. Fairly current, fairly robust, and pretty damn cool. A Windows workalike is XAMPP, which is being ported to Mac now, but the beta is only available for Intel Macs. WAMPServer is also fairly popular on Windows.
To install, simply download the appropriate copy from this page and once unzipped, mount the .dmg file. Then drag into Applications (it MUST be installed directly under the Applications directory else it will fail to run) and you're good.
Now that it's installed, double-click the MAMP.app icon within the Applications/MAMP directory. Feel free to Keep in Dock as you'll be using this app regularly for any testing purposes. If you're a widget fiend, it comes pre-installed with a Dashboard Widget, so you can use that instead. They both require the admin password to invoke.
After entering your admin password, the two servers (Apache and MySQL) will transition from red light to green, indicating a successful start. By default you'll also be taken to the start page for MAMP, from which you can access PHPMyAdmin as well as get some helpful information and links.
You'll probably want to make a few changes to the default installed setup. Personally, I wanted to repoint the Apache root directory to my Mac Sites folder, as this is where I've been storing my sites since I set foot in Mac territory. This is as simple as clicking Preferences… and invoking the Finder dialog from the Apache tab.
Setting Apache to handle all three common naming conventions for index files (index.html and index.php are already covered, but index.htm is strangely left out) requires a quick trip to the Applications/MAMP/conf/apache/ folder. There you'll find the httpd.conf file, which on this particular setup configures Apache. You need to find the line “DirectoryIndex index.html index.php” and tack index.htm to the end or somewhere along the line.
After restarting Apache all of these changes will take effect.
I ran into one issue and can see another similar issue popping up for some who may already run Apache and/or MySQL on their Macs but who are fed up with configuration hassle: Your currently-in-use servers may still be running. To make sure they're not, run the following commands (>$ is an imaginary prompt):
This should clear up any red light issues with MAMP.
You will also want to disable Mac's built-in auto-startup of MySQL. This setting can be found under System Preferences→MySQL. Simply uncheck the “Automatically Start MySQL Server on Startup” box. Optionally, you can also stop a currently running MySQL from this panel rather than running the console command.
To set up virtual hosts for every site in your Sites folder with MAMP there are a few things we need to do. Lets start easy.
pico /etc/hosts ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost www.mysite.dev site2.mysite.dev 255.255.255.255 broadcasthost ::1 localhost
Assuming that you are using port 80 and are pointing to the standard /Users/<username>/Sites folder (like you should be) we will now go into the MAMP httpd.conf file.
In the httpd.conf file go to the bottom ”### Section 3: Virtual Hosts” and add:
# # Use name-based virtual hosting. # # NameVirtualHost * NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /Library/WebServer/Documents ServerName localhost </VirtualHost> Include /Applications/MAMP/conf/apache/includes/*.conf
Also make sure that <Directory … > is the same as DocumentRoot:
Around Line 369 # MAMP DOCUMENT_ROOT !! Don't remove this line !! DocumentRoot "/Users/vincenzo/Sites" Around Line 394 # # This should be changed to whatever you set DocumentRoot to. # <Directory "/Users/vincenzo/Sites">
Now we Create our Virtual Hosts in the Includes folder. Go to the site2.conf file that you created (or whatever you called it) and add:
<VirtualHost *:80> DocumentRoot /Users/<username>/Sites/<folderName> ServerName site2.mysite.dev </VirtualHost>
Now save and quit all files and RESTART MAMP with widget or application. If all is Green your Good to go.
To be able to run apache and MySQL from Terminal while running the MAMP service, you have to create/edit the .bash_profile file.
export PATH=/sbin/:$PATH export PATH=/Applications/MAMP/Library/libexec/:$PATH export PATH=/Applications/MAMP/Library/bin/:$PATH
Now you can type mysql -V or any MySQL command anywhere in terminal as well as apachectl commands.
You have now setup a perfect MAMP web server and are ready to begin Designing and Developing Sites.
Enjoy!