Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I need to setup some VirtualHost records for a MAMP server I have installed on my Mac. In short, rather than using http://localhost:8888/dkbtherapy/index.html I want to use However, with the configuration I've done it doesn't work.

VirtualHost Configuration

In the /Applications/MAMP/conf/Apache folder I modified the httpd.conf file an added this VirtualHost configuration:

<VirtualHost *:8888>
  DocumentRoot /Applications/MAMP/htdocs/dkbtherapy

so that should setup the routing for it (I thought). Then I modified my hosts file and added this:

but when I type in into Safari I get:

Safari can't find the server.

Now, I rebooted the Apache server after making the changes, but I haven't rebooted my Mac. Though I don't think I need to reboot my Mac. What did I miss in the above configuration?

NOTE: after making the changes http://localhost:8888/dkbtherapy/index.html doesn't work now either, I get a 404 returned with this message:

The requested URL /dkbtherapy/index.php was not found on this server.

EDIT: after looking at my Windows box, where I've configured this and it's working, I noticed I missed a line of configuration -it appeared -so I added this to the one on the Mac too:

NameVirtualHost *:8888

EDIT RELATING TO http://localhost:8888/dkbtherapy/index.html: when I look at the error log for Apache I see this error when I try and navigate to that path:

[Fri May 31 11:23:41 2013] [error] [client ::1] File does not exist: /Applications/MAMP/htdocs/dkbtherapy/dkbtherapy

so for some reason it thinks that dkbtherapy is the absolute root for the server it appears -how did I manage that?

share|improve this question

Well, you've defined /Applications/MAMP/htdocs/dkbtherapy as the DocumentRoot for the virtual host, which means that that directory maps to the URL -- so when you visit, Apache maps that to /Applications/MAMP/htdocs/dkbtherapy/dkbtherapy/index.html, which doesn't exist, thus the error you see in the log.

You have two options. One is to change the DocumentRoot value to /Applications/MAMP/htdocs/, which will cause the .../dkbtherapy URL to point where you want it to.

The other option, and in my opinion the preferable one, would be simply to strip /dkbtherapy off your URL, and visit e.g. instead. (I say that's preferable because it seems likely the site, when in production, will have its own domain name, and its URLs won't need to contain /dkbtherapy/. If that's the case, and given that it's always preferable for the development environment to be as close to identical with the production environment as possible, then the second option comes closer to producing that result, and is therefore better than the first.)

One other note regarding your /etc/hosts file: you cannot specify a port number in that file, only an IP address. The "Host not found" error occurs because the TCP stack is unable to parse the entry, and therefore ignores it. The following will work:

With that change in place, as well as the previously described change to the DocumentRoot, should reach the index page of your site.

(Also, you probably don't need the NameVirtualHost line unless you're actually using name-based virtual hosting, which doesn't sound like it's the case right now. It probably won't hurt anything to leave it there until you get around to actually setting up name-based virtual hosts, but removing it shouldn't make a difference to how Apache is behaving, either.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.