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:
127.0.0.1 localhost 127.0.0.1 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:
<VirtualHost 127.0.0.1>
DocumentRoot "/Volumes/Files/http"
ServerName "localhost"
</VirtualHost>

<VirtualHost 127.0.0.1>
DocumentRoot "/Volumes/Files/http/somedomain"
ServerName "somedomain.local"
</VirtualHost>

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

EDIT:
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!

link|improve this question

feedback

3 Answers

up vote 2 down vote accepted

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
</VirtualHost>

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.

link|improve this answer
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 127.0.0.1 and on Linux, at least, you usually bind to 0.0.0.0... not sure what that means, if anything. – Yar Oct 1 '09 at 0:28
though it's weird that you need to specify the port number on OSX.... hmmmm... – Yar Oct 1 '09 at 0:30
feedback

Something like Directory allow from all missing ?

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

link|improve this answer
feedback

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).

link|improve this answer
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
feedback

Your Answer

 
or
required, but never shown

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