How can I access my localhost server from other computers?

后端 未结 8 583
無奈伤痛
無奈伤痛 2021-01-31 05:31

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.

8条回答
  •  礼貌的吻别
    2021-01-31 06:23

    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.

提交回复
热议问题