Using Apache to host websites on local network

user2385136 picture user2385136 · Apr 7, 2011 · Viewed 15k times · Source

I currently use Apache on my machine to test PHP websites locally. I was just wondering how I can allow computers connected to my local network to access the website hosted on my local machine.

Answer

nageeb picture nageeb · Apr 7, 2011

Machines on your local network should be able to access your machine, if only by IP (assuming you don't have a firewall blocking port 80 (HTTP).

Once that's done, you can setup Virtual Hosts in your httpd.conf (look at the very bottom, there should be some sample directives to get you started).

If you want the machines to be able to access multiple different websites on your machine, then you'll need to create local/fake domain names in your VirtualHost setup and also spoof the dns in their .hosts files (c:\windows\system32\drivers\etc\hosts on windows machines).

Essentially what you'll be doing is telling their machines that the website www.testsite.local can be reached at the ip address x.x.x.x, and then your VirtualHost directives will tell apache that the website www.testsite.local can be found at /home/user/public_html/