Accessing localhost (xampp) from another computer over LAN network - how to?

后端 未结 24 3098
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 14:01

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.

相关标签:
24条回答
  • 2020-11-22 14:33

    Access localhost from Remote Device

    Prerequisite: Your website is currently on http://localhost:8081/ with a tool like live-server

    a) Publish on Same Network

    Within the same network, you can access your machine with your current ip address or hostname. You can find the ip address running ipconfig | grep IPv4 or the hostname by sending a ping -a to that ip.

    http://192.128.1.18:80/
    http://hostname:80/

    Note: For best results, use port 80, connect on a private network, and check your firewall settings.

    b) Publish on Any Network (easier)

    1. Opt 1 - You can use ngrok to provide port forwarding over ngrok's public facing ports

      Download ngrok and run the following command:

      $ ./ngrok http 8081
      

    2. Opt 2 - You can use localhost.run to create a ssh tunnel with the following command:

      ssh -R 80:localhost:8081 kylemit@ssh.localhost.run
      


    Access Remote Device from Local Dev Tools

    To connect your browser dev tools with a connected device, follow the instructions at Get Started with Remote Debugging Android Devices

    1. On your phone, enable Developer Options & USB Debugging
    2. Plug your phone into your computer via USB and set the protocol (not File / Media Transfer)
    3. Open Dev Tools > More Tools > Remote Debugging (try here if Device Not Detected)

    4. Find your site and Click Inspect which will open up a new inspector window


    Further Reading:

    • How do I connect to this localhost from another computer on the same network?
    • Access to a site on localhost from remote
    • How to debug web sites on mobile devices?
    0 讨论(0)
  • 2020-11-22 14:35

    First you go to Command Prompt and type

    Notepad C:/windows/system32/drivers/etc/hosts

    then add your ip adress below then the url of your site.

    Second you go to Command Prompt and type notepad c:/xampp/bin/apache/apache2.4.18/conf/extra/httpd-vhosts.conf

    then add this below

    documentroot "Directory of your site"
    Allow from all
    Require all granted
    
    0 讨论(0)
  • 2020-11-22 14:35

    So I was trying to solve a similar problem with connecting to a totally different server on my own LAN so that when power is interrupted and then restored that my server comes back online and other systems can still have connectivity with automation. However, my problem was DHCP giving my server a diff IP on occasion. This thread answered my problem with the NAMESERVER that windows have natively. I was connecting directly to my servers IP add http://192.168.1.5 through a batch file to initialize the connection but when power problems happen it would not connect. I changed the .bat file to point at http://DESKTOP-actualnamewhereserver:port and done. Problem solved. IF I don't change my computers names then when DHCP hands DESKTOP-actualnamewhereserver a new IP address it will still identify as its own name on the LAN and therefore be able to accept the connection regardless of it's IP Address. Simply give the other people on your wireless LAN the name of your pc hosting the Apache server and lets say its name is DESKTOP-DOUGHFACTORYHUT they will type http://DOUGHFACTORYHUT:80 or whatever port number your apache config is set to host at like LOCALHOST:80 which essentially are the same thing attached to your local Dynamic IP address assigned by DHCP or STATIC IP you have set to the server.

    0 讨论(0)
  • 2020-11-22 14:36

    Localhost is just a name given for the loopback, eg its like referring to yourself as "me" ..

    To view it from other computers, chances are you need only do http://192.168.1.56 or http://myPcsName if that doesnt work, there is a chance that there is a firewall running on your computer, or the httpd.conf is only listening on 127.0.0.1

    0 讨论(0)
  • 2020-11-22 14:36

    If you are connected to Wi-Fi network, then it is much simpler. Just find the Ip in which you have connected to the Wi-Fi. Eg:

    your-ip is "10.10.55.67".

    Then start the xampp server in your machine.

    Then in anyother computer connected to the same Wi-Fi n/w, type

    http://your-ip

    Eg:http://10.10.55.67

    0 讨论(0)
  • 2020-11-22 14:36

    If someone is still finding it hard, this simple thing worked for me:

    1. On you main system let's say Hosting PC... Go to Control Panel > Windows Defender Firewall > Allow an app or feature through Windows Defender Firewall > Change settings > Find "Apache HTTP Server" > Check both the check-boxes (under Private & Public). See Screenshot

      • In my case there were two "Apache HTTP Server" entries, so I checked both the check-boxes for both entries.
    2. On any another system connected over a same network... Open browser > type: your hosting pc's IP adress followed by your project name in the url bar. Example: 192.168.72.111/example.com/

    Hope it helps! Thanks.

    0 讨论(0)
提交回复
热议问题