Accessing multiple sites from local network
Posted by: pentool (209.221.168.---)
Date: May 20, 2015 01:24AM

Hi,

I'm trying to create and access multiple sites from local network. So let's say I have two sites: www.site1.com and www.site2.com. These are local names only, and they are setup in my vhosts file.

My virtual hosts are as follows:

<VirtualHost *:80>
DocumentRoot "C:/websites/site1"
ServerName www.site1.com
<Directory "C:/websites/site1">
Options Indexes FollowSymLinks
Allow from all
AllowOverride All
Require all granted
Order Deny,Allow
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/websites/site2"
ServerName www.site2.com
<Directory "C:/websites/site2">
Options Indexes FollowSymLinks
Allow from all
AllowOverride All
Require all granted
Order Deny,Allow
</Directory>
</VirtualHost>


The windows hosts file setup as such:

127.0.0.1 www.site1.com
::1 www.site1.com

127.0.0.1 www.site2.com
::1 www.site2.com


The httpd.conf file is setup to listen on:

Listen *:80


This all works on the local machine. I can go to www.site1.com and it serves up site1; and I can go to www.site2.com and will serve up site2.

I can also go to a remote machine on the local network, and type in the IP adress of this box. Let's say the IP of this box is: 10.30.100.50. So entering this IP on the remote machine will show me site1. So far so good.

However, how do I access site2 from the remote machine? I don't seem to be able to figure this out. None of the following seems to be correct:
10.30.100.50/site2
10.30.100.50/www.site2.com (... this seems to be totally incorrect, but tried it for the heck of it)

How can I setup multiple sites so that I can access them from a machine on the local network as well?

Thank you!

Options: ReplyQuote
Re: Accessing multiple sites from local network
Posted by: Otomatic (Moderator)
Date: May 20, 2015 10:11AM

Hi,

Quote
pentool
Allow from all
AllowOverride All
Require all granted
Order Deny,Allow
It is a strange mixture of Apache 2.2 directives with Apache 2.4 directives.
Please answer to READ BEFORE YOU ASK A QUESTION

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Accessing multiple sites from local network
Posted by: pentool (---.evrt.wa.frontiernet.net)
Date: May 20, 2015 09:20PM

My apologies.

1. Windows Server 2012 R2
2. WAMP server 2.5 x64
3. Apache 2.4.9
4. PHP 5.5.12
5. MySQL 5.6.17
6. Color is green. As I mentioned, everything works fine on local machine.

8. Yes, I do have access to localhost
9. Yes, I do have access to phpmyadmin
12. Install path: C:\wamp

Options: ReplyQuote
Re: Accessing multiple sites from local network
Posted by: Otomatic (Moderator)
Date: May 21, 2015 10:00AM

Hi,

How to use VirtualHosts : [forum.wampserver.com]

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Accessing multiple sites from local network
Posted by: pentool (---.evrt.wa.frontiernet.net)
Date: May 21, 2015 06:27PM

Thank you. I have already seen that post a few months ago. I've also done quite a few google searches before coming here because I could not find what I was looking for. I don't have a problem with Virtual Hosts. I have a problem accessing the sites via local network.

Options: ReplyQuote
Re: Accessing multiple sites from local network
Posted by: Otomatic (Moderator)
Date: May 21, 2015 07:07PM

Hi,

Your VirtualHosts must be declared like this:
<VirtualHost *:80>
  DocumentRoot "C:/websites/site2"
  ServerName www.site2.com
  <Directory "C:/websites/site2">
    Options Indexes FollowSymLinks
    <RequireAny>
      Require local
      Require ip xxx.xxx.xxx.xxx
    </RequireAny
  </Directory>
</VirtualHost>
Where xxx.xxx.xxx.xxx is IP of the network PC.
For multiple network PC you can add the ip's like:
    Require ip xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy zzz.zzz.zzz.zzz
or use abbreviated ip like 192.168.000 for all ip's from 192.168.000.001 to 192.168.000.254

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Accessing multiple sites from local network
Posted by: pentool (209.221.168.---)
Date: May 22, 2015 07:36PM

Thank you! This seems to work. What I had was working also.

But the question is, how do I access the sites from a local network? From the local machine, it is not an issue. When I enter "www.site1.com" or "www.site2.com" into the browser, they all work fine.

But how do I get to the sites from a local network? I can't enter "www.site1.com" or "www.site2.com" because those addresses do not exist on a remote machine. They only exist on the local machine that is running WAMP.

Let's assume the machine's IP that is hosting WAMP is 10.30.100.50. When I enter this IP into the browser on a remote machine on a local network, I get the first site (which would be equivalent to www.site1.com). But how do I get to the second site (which would be www.site2.com)?

I can't simply enter the same IP (10.30.100.50) because that gives me the first site only. I do not understand what do I need to make this happen.

Options: ReplyQuote
Re: Accessing multiple sites from local network
Posted by: pentool (209.221.168.---)
Date: May 22, 2015 09:14PM

Thanks for your help, but I went with a different solution.

Options: ReplyQuote


Sorry, only registered users may post in this forum.