localhost webdev: virtual host setup on Mac OS X with MAMP

23 October, 2008 - 11:28

Reminder to self: how to set up a virtual host for localhost webdevelopment on OS X with MAMP

  1. DNS setup: add an entry for the local domain name in /etc/hosts, e.g.
    127.0.0.1     foo.localhost

    and flush DNS cache with

    dscacheutil -flushcache

  2. Apache config (/Applications/MAMP/conf/apache/httpd.conf): add a virtual host entry like
    <VirtualHost *>
      ServerName foo.localhost
      DocumentRoot /Users/eddywally/Sites/foo/localhost-dev/drupal
    </VirtualHost>

    and restart webserver, e.g. with

    /Applications/MAMP/bin/apache2/bin/apachectl restart

  3. Connect to http://foo.localhost:8888 (don't forget the nonstandard port number, unless you configured MAMP to use standard port 80).

further reading:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • No HTML tags allowed
  • Lines and paragraphs break automatically.

More information about formatting options