MAMP setup

MAMP is a web server stack for Mac.

These note give step by step instructions on how to set up a site on MAMP. We’ll call the site “testsite”. It will be configured as a “virtual host”, as this approach will allow you to easily run multiple sites locally, each with a different domain name.

  1. Tell MAMP that you’re going to be using virtual hosts via port 80.

    Edit /Applications/MAMP/conf/apache/httpd.conf. You should find a configuration setting ‘Listen 8888’. Change it to the following:

    Listen 80

    Next, tell MAMP where your virtual hosts are configured by adding the following line to the end of the file:

    Include /Applications/MAMP/conf/apache/vhosts.conf

    Save the file. From now on MAMP can serve web sites using whatever domain name you choose and you will not have to add :8888 to the end because it’s using port 80, the default port for web pages.

    You should not have to edit httpd.conf again. From now on you will only need to follow the next steps in order to add a new site to MAMP.

  2. Tell your computer to look on itself when you ask for the “testsite” domain name.

    Edit /etc/hosts. The first uncommented line should start with Add testsite to the end of this line, separated by a space. So you’ll have something like this: localhost testsite

    Save the file. Now when you type http://testsite/ into your browser, your computer will ask itself for the site. Remember the trailing slash.

  3. Create the site files.

    Create a folder called “testsite” in /Applications/MAMP/htdocs/ and place your site’s file into it. You should now have /Applications/MAMP/htdocs/testsite that contains all of the site files, e.g. if you place an index.html file in there it’ll be loaded when you later request http://testsite/.

  4. Tell MAMP about the domain name and files.

    Edit /Applications/MAMP/conf/apache/vhosts.conf. Add the following virtual host setup:

    <VirtualHost *:80>
      ServerName testsite
      DocumentRoot /Applications/MAMP/htdocs/testsite/
      <Directory /Applications/MAMP/htdocs/testsite/>
        Order allow,deny
        Allow from all
        Options FollowSymLinks
  5. Restart MAMP and test the site.

    Stop then start the MAMP servers. Visit http://testsite/ in your browser and you should see the site’s index page.

  6. Create the site database.

    If the site needs a database, run the following command in a terminal to create a database called “testsite”:

    /Applications/MAMP/Library/bin/mysqladmin -uroot -proot create testsite

    (By default MAMP sets the database user to root and its password to root)

    If you have a database dump you’d like to import, do this with the following command (which imports a dump file called “testsite-dump.sql” into the testsite database):

    /Applications/MAMP/Library/bin/mysql -uroot -proot testsite < testsite-dump.sql
  7. Tell the site about the database.

    If the site needs a database, then presumably you’ll need to tell your web application about it. E.g. for Drupal, edit /Applications/MAMP/htdocs/testsite/sites/default/settings.php and update the database configuration around line 92 with the database access details:

    $db_url = 'mysql://root:root@localhost/testsite';
  8. Restart MAMP and test the site.

    Stop then start the MAMP servers. Visit http://testsite/ in your browser and you should see the site.

Last modified: 20/09/2012 Tags: ,

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top