MAMP host & vhosts

You Must Use the MAMP files, NOT the Apple default system versions!

  1. Update the hosts file in /etc/hosts
    add:
    127.0.0.1 newsitename.local
  2. Create a vhost in: /Applications/MAMP/conf/apache/extra/httpd-vhost.conf
  3. In this file: /Applications/MAMP/conf/apache/httpd.conf
    Uncomment this line
    #Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
  4. Then in httpd-vhosts.conf, add a default localhost vhost, AND any new sites you need:
<VirtualHost *:80>
    DocumentRoot "/Applications/MAMP/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin youremail@yourdomain.com
    DocumentRoot "/Applications/MAMP/htdocs/newsitename"
    ServerName newsitename
    ServerAlias newsitename
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

Then check via Terminal:
cd /Applications/MAMP/Library/bin
apachectl -S

NOTES!

If you’re using these, they’re not going to work!
/etc/apache2/httpd.conf
/etc/apache2/extra/http-vhost.conf

If you’re pointing to a WordPress, you’ll have to update domain values in the database, and possibly wp-content.php for it not to forward after the server logic, to the values in the db!

Leave a Reply

You must be logged in to post a comment.