I've been using Xampp on Windows for some time now. I'm trying to set it up on Mac OS X also, so I copied all the configuration, but I can't get virtual hosts to work.

1- I included this in /private/etc/hosts: localhost somedomain.local

2- I included this in httpd.conf:
DocumentRoot "/Volumes/Files/http" Include etc/extra/httpd-vhosts.conf

3- I included this in httpd-vhosts.conf:
DocumentRoot "/Volumes/Files/http"
ServerName "localhost"

DocumentRoot "/Volumes/Files/http/somedomain"
ServerName "somedomain.local"

Which is basically the same configuration I have on Windows. The result I get on MacOS is that any domain defined in the hosts file gets you to httpd.conf's DocumentRoot, I.E. /Volumes/Files/http and not to the virtual host's root. Any ideas?

New tags: apache-vitual-hosts vhosts vhosts.conf virtual-hosts

Thanks for all the answers. I've tried to work it out, moved the line Include etc/extra/httpd-vhosts.conf to another place in httpd.conf ( don't ask why ) and it worked. But the problem now seems to be that the only virtual host that is recognized is the first that's defined.

All the domains defined on /etc/hosts point now to that virtual host. If I comment it out in httpd-vhosts.conf and restart apache, then all domains point to the second one.

It seems that declaring all is the problem? ( but it's not on windows )
I tried * and didn't work. I'll try *:80 and see what happens. Thanks!


This works on OSX

<VirtualHost *:80>
    ServerAdmin apache-consulting@confusionconsultants.com
    DocumentRoot "/dans-data"
    ServerName dans-data.localhost
    ErrorLog "logs/dans-data-on-localhost.log"
    CustomLog "logs/dummy-host2.example.com-access_log" common

so try something similar. Good luck.

Edit: Note that there are several differences, but most notably, the port number. Some of these lines are definitely optional, like the Error and CustomLog lines.

  • Thnaks, worked like a charm. How strange that ip-based virtual hosts work differently on two versions of the same software. – Petruza Sep 30 '09 at 12:29
  • To put it in perspective, I'm not an expert but the localhost/loopback concept is a bit weird. You were binding to and on Linux, at least, you usually bind to not sure what that means, if anything. – Dan Rosenstark Oct 1 '09 at 0:28
  • though it's weird that you need to specify the port number on OSX.... hmmmm... – Dan Rosenstark Oct 1 '09 at 0:30

Something like Directory allow from all missing ?

see : http://www.phpmagicbook.com/how-to-setup-vhosts-on-xamp/


I beleive you'd have to install either the linux or Mac OSX version of xampp if they have one.

http://www.apachefriends.org/en/xampp-macosx.html seems to be the one.

I don't think the software works platform independently due to the way file structures are set within each operating system. For example, it is hard to define the linux equivalent of C:/xampp/htdocs and /opt/lampp/htdocs (not sure what it is for Mac).

  • Ok thanks, at least you tried. Of course I'm running the Mac OSX version. Apache works, as it serves, as I wrote, the files on the DocumentRoot. PHP works, and MySQL works fine as well. The only problem is that I can't get apache's virtual hosts to work properly. But thanks anyway! – Petruza Sep 28 '09 at 12:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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