4
votes

I try to set up virtual host for some local site with XAMPP.

I executed next steps:

  1. In "C:/xampp/apache/conf/extra/httpd-vhosts.conf" I added:
<VirtualHost *:8081>
    DocumentRoot "C:/xampp/htdocs/"
    ServerName localhost
</VirtualHost>
<VirtualHost *:8081>
    DocumentRoot C:/xampp/htdocs/fw/public
    ServerName fw.local.com
    <Directory "C:/xampp/htdocs/fw/public">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
  1. Inside "C:/Windows/System32/drivers/etc/hosts" I added:
127.0.0.1       localhost    
127.0.0.1       fw.local.com
  1. Restarted Apache.

And...

If I follow to:

http://localhost:8081/

All is OK: I see my catalog with projects in folder "htdocs".

But! If I follow to:

http://fw.local.com/

I expect to see result of my "index.php" file inside "..htdocs/fw/public". But I get:

This site can’t be reached
fw.local.com refused to connect.

File "C:/xampp/apache/conf/httpd.conf" contains:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Where I was wrong?

1

1 Answers

3
votes

You should change: <VirtualHost *:8081> to <VirtualHost *:80> on both counts, fw.local.com attempts to connect to port 80, not 8081.

Edit: You could also keep it the way you have it and connect to: http://fw.local.com:8081/