1

I'm having trouble getting Virtual Hosts to work on MAMP.

Here's my hosts file:

127.0.0.1 localhost
127.0.0.1 mysite

Here's my httpd-vhosts.conf file:

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80



#
# Custom Virtual Hosts
#
<VirtualHost *:80>
    DocumentRoot "/Users/(username)/Documents/"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Users/(username)/Documents/foo/bar/"
    ServerName mysite
    <Directory "/Users/(username)/Documents/foo/bar/">
        AllowOverride all
    </Directory>
</VirtualHost>

My httpd.conf looks like this:

# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

http://mysite doesn't work. I restarted the apache servers multiple times. I've taken a look into multiple threads on this subject on here, but I can't figure out what's wrong.

EDIT: btw, I'm using /Users/(username)/Documents as my document root for MAMP, maybe I should replace those with the usual /Applications/MAMP/htdocs anyway ?

yurden
  • 152
  • 1
  • 16
  • We're having the problem here, and we _think_ it's the default `localhost` that's jamming things up by preventing connections going beyond its path. So, for example, `localhost` is: "/Library/WebServer/Documents/" and `ClientName` is: "/Library/WebServer/Documents/ClientName" but when we visit the client web address, we get routed to: `localhost`. – Wayne Smallman Aug 07 '17 at 12:46
  • Did you ever find a fix, @Wayne? – DB1500 Jan 28 '18 at 03:46
  • @DB1500, in the Hosts panel, I created a new host, and then chose the location from "Document root" on the right hand side. I didn't edit or create a host file myself and let MAMP Pro handle the entire thing. If you need more help, reach out via chat. – Wayne Smallman Jan 29 '18 at 08:53
  • I remember having so many issues using MAMP and OS X. Switch to Linux ;) joking (well..) aside, check to see if port 80 is a conflict port (as in, is another application/service using it [like shitty skype]), – treyBake Jul 31 '18 at 12:26

1 Answers1

1

Check that the ports you set for apache is what you set in your httpd-vhosts.conf file. If its port 80. it should be same in your Mamp apache port.

Aliu
  • 36
  • 3