Search code examples
apachemampvirtualhostvhosts

Virtual hosts for MAMP 4.1.1 on MAC 10.12.6 not working


I know this has been asked hundreds of times and I made sure I read all of them, but still I cannot get this working. So as the title suggests, I cannot get a vhost running from MAMP/OSX. Here's a list of things I tried so far:

Created configuration in /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot /Applications/MAMP/htdocs
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Applications/MAMP/htdocs/abcd/public"
    ServerName abcd.dev
    ServerAlias www.abcd.dev
</VirtualHost>

Removed comment from the line

Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

in the file /Applications/MAMP/conf/apache/httpd.conf

Finally this is how my /etc/hosts file looks

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

127.0.0.1       abcd.dev

Restarted MAMP and here are the test results:

http://localhost/ - Shows Index of and then /abcd

http://127.0.0.1/ - Shows Index of and then /abcd

abcd.dev - Unable to connect, Firefox was unable to connect to the server abcd.dev

Surprisingly

ping abcd.dev - Returns response 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.053 ms

ping 127.0.0.1 and ping localhost also returns same response.

I had docker running on my computer, I thought that was messing it up, so I stopped in completely, but the problem continues.

Any help is appreciated.


Solution

  • abcd.dev is now officially a public domain. So basically my browser is trying to locate the site "out there".

    Instead let's use something like abcd.local or abcd.loc

    Hope this helps someone stuck in .dev labyrinth.