macosapachexampp

Setting up a virtual host on XAMPP on Mac


I am trying to set up a virtualhost on my apple mac on localhost. The server is provided by XAMPP, which bundles Apache/MySQL/PHP in one bundle.

Here is what I have done so far:

Edited /private/etc/hosts to include 127.0.0.1 to point to test.myserver.local

127.0.0.1       test.myserver.local

Edited /Applications/XAMPP/etc/extra/httpd-vhosts.conf to inlcude my vhosts details

<VirtualHost *:80>
   DocumentRoot /Users/???/Documents/workspace/trunk/htdocs
   ServerName test.myserver.local
  <Directory "/Users/???/Documents/workspace/trunk/htdocs">
     AllowOverride All
  </Directory>
</VirtualHost>

Placed a simple index.html in there with the word test in it.

I have restarted the server, and then browse to the test url to be greeted with Apache's default page instead of my test page. The vhosts file works for another virtual host, the code is copied with the respective bits changed (i.e. folder paths), the hosts file works, as when Apache is turned off, my browser says server not found.

Why is Apache refusing to show up my test code? Are there any other files I need to change? I cant think of any others, its usually just those on linux/windows.


Solution

  • Have you told Apache to actually use name-based virtual hosting?

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

    I don't believe it's enabled by default in Xampp on Mac.