4

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.

Husman
  • 6,819
  • 9
  • 29
  • 47
  • 1
    Can you show us what you have edited in `/private/etc/hosts`, `/Applications/XAMPP/etc/extra/httpd-vhosts.conf` and update it in the question? Did you restart the Apache server after editing them? – Praveen Kumar Purushothaman Mar 04 '13 at 16:47
  • You restarted apache afterwards right? – prodigitalson Mar 04 '13 at 16:48
  • I tried, but it seems to remove all my tags, so it doesnt look good. I'll try again. – Husman Mar 04 '13 at 16:48
  • @prodigitalson absolutely. I've done this a fair few times, so Im a little stumped. – Husman Mar 04 '13 at 16:48
  • 1
    I once heard that there was a problem with certain versions of XAMPP if you didn't leave the localhost vhost entry in there... You might want to try adding that back. Long shot, but maybe... :) – Aaron Saray Mar 09 '13 at 01:43
  • Maybe the virtualhost config isn't loaded in the first place. Something like `Include /Applications/XAMPP/etc/apache2/extra/httpd-vhosts.conf` could be commented out in `httpd.conf`. – Bart Mar 12 '13 at 18:41
  • It certainly is loaded. Apache complains if theres a typo in the file. – Husman Mar 12 '13 at 22:10
  • I've *sometimes* had problems with using a name that ends with `.local`. Are your other vhosts also in the `.local` top-level or are they something else? If they are something else, make this one something else too. – Moshe Katz Mar 13 '13 at 16:01
  • can you try to use another port, let's say 8080. Maybe there is a conflict of more than one site configured with the same port. – Ateszki Mar 13 '13 at 19:13

3 Answers3

9

On xampp you need to edit 3 files to setup virtual hosts

the /etc/hosts and /Applications/XAMPP/etc/extra/httpd-vhosts.conf as you did.

But also you need to edit /Applications/XAMPP/xamppfiles/etc/httpd.conf to include the http-vhosts.conf

make sure you have uncommented this line

# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

EDIT

Have you tried to add this lines

Order allow,deny
Allow from all

Just before the

AllowOverride All
Ateszki
  • 2,243
  • 1
  • 16
  • 13
1

Try leaving the the setting for "localhost" at the end of the file "httpd-vhosts.conf", i.e.:

#
# Virtual Hosts
#
...

# others vhost
<VirtualHost *:80>
...
</VirtualHost>

# localhost
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
    <Directory "/Applications/XAMPP/xamppfiles/htdocs">
        Options Indexes FollowSymLinks Includes execCGI
        AllowOverride All
        Order Allow,Deny
        Allow From All
    </Directory>
</VirtualHost>
#end of httpd-vhosts.conf file

Worked for me, greetings!

Gerson
  • 101
  • 2
  • 6
0

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.

Danack
  • 24,939
  • 16
  • 90
  • 122