4

I have just set up a wi-fi network at home. I have all my files on my desktop computer (192.168.1.56) and want to access localhost over there from another computer (192.168.1.2).

On my desktop I can access localhost through the normal http://localhost. Apache is running on port 80 as usual.

Exactly what do I have to do to achieve this? There is documentation on the net but they either don't work or are too fragment and confusing to understand.

I think I have to make changes to my apache's httpd.conf file and the hosts file. Any ideas as to what changes to make?

bcosynot
  • 141
  • 1
  • 1
  • 5

2 Answers2

4

localhost is the name given to the IP loopback address 127.0.0.1. Every computer in a network has a localhost address that points to itself. To access your files on your main computer you can use http://192.168.1.56. You could also edit the hosts file on the client(s) and assign a name to 192.168.1.56 edit /etc/hosts (unixlike systems) or %SystemRoot%\system32\drivers\etc\hosts for windows systems e.g.

192.168.1.56    homeserver.lan 

then you will be able to access the server as http://homeserver.lan

Edit: From the comments below, the port was being blocked by a firewall.

user9517
  • 114,104
  • 20
  • 206
  • 289
  • but I am not able to access http://192.168.1.56 (the IP address is dynamic, does that make a difference?) or http://desktoppcname... i really doubt that making changes to the hosts file will make any difference... – bcosynot Apr 03 '11 at 10:19
  • @vr3690: Check that your desktop pc will allow connections through it's firewall on port 80 (http). – user9517 Apr 03 '11 at 10:53
  • bingo. when i use http://192.168.1.56 on desktop pc, i am able to see the site. so I am guessing I have a firewall problem. how do I fix this? – bcosynot Apr 03 '11 at 10:56
  • @vr3690: You don't provide any information about the OS on your desktop PC. If it is windows have a look [here](http://www.windowsecurity.com/articles/Customizing-Windows-Firewall.html) – user9517 Apr 03 '11 at 11:10
  • yes. got it working. allowed port 80 limiting the scope to my subnet. thanks. – bcosynot Apr 03 '11 at 11:13
-1

Out of the box Apache's default vhost configs might offer something if you try this in your browser: `http://192.168.1.56'.

If that works look in the /etc/apache2/sites-enabled/000-default file (this may differ slightly on your OS) and change DocumentRoot to point to where the files you want to access are.

This isn't exactly secure if both machines are connected to the Internet but if you're not Port Forwarding on a NAT router to port 80 out to the Internet for serving Web pages then it's not the end of the world.

Remember to /etc/init.d/apache2 restart or similar after changes.

(It's probably worth saying at this point that using HTTP to share files across a LAN probably it's the obvious and ideal solution but the myriad of other solutions available are outwith this question most likely).

Jonathan Ross
  • 2,173
  • 11
  • 14