Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access my localhost server from other computers?

Tags:

php

apache

wamp

I'm new to PHP, so I don't know how to explain it. I'm running WAMP on my computer and I would like to be able to access my localhost from another computer.

Is it possible? How can I do this?

like image 606
Prathyash Prasanthan Avatar asked Apr 08 '12 17:04

Prathyash Prasanthan


People also ask

How can I access localhost from anywhere?

http://localtunnel.me. http://localhost.run. We can use either of them to achieve our end goal.

How do I access my local server?

Usually, you can access the localhost of any computer through the loopback address 127.0. 0.1. By default, this IP address references a server running on the current device.


1 Answers

This is provided that all machines are on the same network and that you have administrative privileges on the machines (you'll have to edit some system files).

You can easily do this but it would have to be a manual process.

You have to create an entry in the hosts file -

  • On Windows machines is is located in %SystemRoot%\system32\drivers\etc\hosts
  • On UNIX like systems it is located in /etc/hosts

http://en.wikipedia.org/wiki/Hosts_(file)#Location_in_the_file_system.
See the link for details on where your hosts file is located. It depends on the operating system.


The following will have to be done on every machine that you would like
to have access to your localhost machine.

Add a line at the very end of your hosts file similar to this :

10.0.0.42       prathyash-localhost.com

The IP address (in the example above it is 10.0.0.42) is the address of your localhost; Your computers IP address. The domain name (prathyash-localhost.com) is what is mapped to the IP address.

After you save that file, whenever that computer points to prathyash-localhost.com, it will be directed to your IP address. Firewalls are still a barrier - however the other answers covered that so I will not repeat their contribution.


Depending on your situation, manually editing tens maybe hundreds of files might not be feasible. In this case, you might want to consult the networks administrator (he probably hangs around on Server Fault), and he may have a better solution for you.

like image 167
Lix Avatar answered Oct 19 '22 07:10

Lix