0

I have created a multi site for wamp and this is working fine on the server pc but not sure how to access these sites from a network. I put all the sites' folders just in the root of wamp, a folder before the 'www'.

here's a part of the apache conf

#virtual sites

NameVirtualHost *:80

<VirtualHost 127.0.0.1>
    ServerName localhost
    DocumentRoot "C:/wamp/www"
</VirtualHost> 

<VirtualHost 127.0.0.1>
    ServerName client1.localhost
    DocumentRoot "C:/wamp/client1"

    <Directory "C:/wamp/client1">
        allow from all
        order allow,deny    
        AllowOverride All
        Require all granted
    </Directory>

    DirectoryIndex index.html index.php
</VirtualHost>
<VirtualHost 127.0.0.1>
        ServerName client2.localhost
        DocumentRoot "C:/wamp/client2"

        <Directory "C:/wamp/client2">
            allow from all
            order allow,deny    
            AllowOverride All
            Require all granted
        </Directory>

        DirectoryIndex index.html index.php
    </VirtualHost>

and here's the hosts entry

127.0.0.1       localhost
127.0.0.1   client1.localhost
127.0.0.1   client2.localhost
127.0.0.1   client3.localhost

This works fine in the server's pc browser by going to x.localhost (x = client folders). I changed the hosts file on the client pc to this:

127.0.0.1       localhost
192.168.0.100   main
192.168.0.100   client1.main
192.168.0.100   client2.main
192.168.0.100   client3.main

On the client's browser these urls all shows the main wampserver index.php and not its assigned folder/site.

2
  • 1
    Try to set <VirtualHost *:80> (port number instead of IP)
    – Dezigo
    Oct 28, 2013 at 11:34
  • What version of Apache are you using? You have a muddle of 2.2 and 2.4 commands in your config.
    – RiggsFolly
    Nov 1, 2013 at 0:11

1 Answer 1

1

Assuming you are using Apache 2.4.x this is more likely to work:

#virtual sites

#NameVirtualHost is no longer required in Apache 2.4.x so get rid of it.
#NameVirtualHost *:80

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/wamp/www"
    # allow access from only this PC (security)
    Require local
</VirtualHost> 

<VirtualHost *:80>
    ServerName client1.main
    DocumentRoot "C:/wamp/client1"
    Options Indexes FollowSymLinks
    <Directory "C:/wamp/client1">
        AllowOverride All
        Require local
        # allow access from any ip in my subnet but not the internet
        Require ip 192.168.0
    </Directory>
    DirectoryIndex index.html index.php
</VirtualHost>

<VirtualHost *:80>
    ServerName client2.main
    DocumentRoot "C:/wamp/client2"
    Options Indexes FollowSymLinks
    <Directory "C:/wamp/client2">
        AllowOverride All
        Require local
        # allow access from any ip in my subnet but not the internet
        Require ip 192.168.0
    </Directory>
    DirectoryIndex index.html index.php
</VirtualHost>

Now your networked PC's should be able to find the correct site using the HOSTS file you have setup on each of them.

I dont know what this line in the hosts file was for so you could remove it.

192.168.0.100   main

So the network PC's have this as their HOSTS file

127.0.0.1       localhost
192.168.0.100   client1.main
192.168.0.100   client2.main
192.168.0.100   client3.main

The client PC's then use http://client1.main to get to the first site and http://client2.main to get to the second .. etc

Of course you would then also have to address the sites from the PC running WAMPServer as http://client1.main as well. And change the HOSTS file on the WAMPServer PC to be the same as the ones on the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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