2

I have search long enough but can't bump into the answer.

I have ubuntu 16.04 installed for local web development in one machine on a local area network. I have done installing LAMP etc.

I have different websites installed here.

  1. main server name is server1.example.com
  2. test.example.com
  3. foo.example.com

I can access each test website fine from the ubuntu server itself.

My problem is, they all point to the same ip (192.168.1.100) which is the server ip addres.. from other machine when i type http://192.168.1.100 i always get the main webserver content ie. server1.example.com

My question. How do i access test website 2 and 3 from other machine in the LAN? Like when i want to work with test.example.com what will be the address i typed on the browser??

Is it possible to attain what i'm trying on a Local Area Network?

Thankyou in advance.

1 Answer 1

0

On client machine add server1.example.com, test.example.com and foo.example.com to /etc/hosts file:

192.168.1.100 server1.example.com test.example.com foo.example.com

Then check if it works, in terminal issue the following command

ping -c 1 server1.example.com
ping -c 1 test.example.com
ping -c 1 foo.example.com

If names are resolved then check in browser if you can access sites test.example.com and foo.example.com

5
  • i have done that and as i have said, it all worked from the server (ubuntu machine say PC1) but when i try to access it from other machine in local area network (say PC2) i don't know how to access foo.example.com and test.example.com because typing the address 192.168.1.100 always shows me the server1.example.com content. my host file settings is 127.0.0.1 localhost 192.168.1.100 server1.example.com server1 192.168.1.100 test.ecample.com 192.168.1.100 foo.example.com Jun 1, 2016 at 17:14
  • Modify hosts files in clients on your LAN, or setup DNS to return 192.168.1.100 for those addresses. Use domain names not numeric IPs. VirtualHosts depend on domain names.
    – user195607
    Jun 1, 2016 at 17:21
  • Thanks, But problem is, when i edit hostfiles say 192.1681.100 test.example.com, it points to the same ip 192.168.1.100 which is server1.example.com contents. My question is, how do i point to test.example.com do i have to add something else?? in cpanel we used to do ip/~username. so how do i point to all 3 specific test web on my LAN PC (PC2) Jun 1, 2016 at 17:41
  • Use single IP address followed by multiple domain names separated by spaces in hosts file on client machine. Then use those domain names in your browser. Do not use numerical IPs.
    – user195607
    Jun 1, 2016 at 17:57
  • Thanks mate!!! been trying to make this happen for 3 days now :) now you solved my problem. Thank you so much Jun 1, 2016 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .