我目前正在做一个项目,我想在家里的两台笔记本电脑上进行测试,其中一台笔记本电脑连接到另一台本地主机。我正在使用XAMPP。我怎么做呢?
当前回答
在Mac OS X上:
在终端中,运行ifconfig以获得计算机在其当前网络上的内部IP。它可能是192.168.1.140或10.0.1.174之类的东西。 启动服务器。例如,node server.js可以在某个端口上启动服务器。 在您的手机上,访问IP地址(例如192.168.1.140:3000),并确保指定端口。
其他回答
it may be that your firewalls are preventing you from accessing the localhost's webserver. Put the IP addresses of both of your computers' internet security antivirus network security as safe IP addresses if required. How to find the IP address of your windows PC: Start > (Run) type in: cmd (Enter) (This opens the black box command prompt) type in ipconfig (Enter) Let's say your Apache or IIS webserver is installed on your PC: 192.168.0.3 and you want to access your webserver with your laptop. (laptop's IP is 192.168.0.5) On your PC you type in: http://localhost/ inside your Firefox or Internet Eplorer browser to access your data on your webserver. On your laptop you type in http://192.168.0.3/ to access your webserver on your PC. For all these things to work you need have installed a webserver correctly (e.g. IIS, Apache, XAMP, WAMP etc).
如果它不工作,试着从你的笔记本电脑ping你的PC: 在笔记本电脑上打开命令提示符:启动> cmd(输入) ping 192.168.1.3 (Enter) 如果ping不通,说明防火墙阻止了您的连接,或者网络布线有问题。重新启动调制解调器或网络交换机和机器。 关闭正在使用您的端口的聊天程序等程序。 您也可以尝试不同的端口号: Http:192.168.0.3:80或Http:192.168.0.3:81或后面的任意随机数
如果在执行上面的步骤之后,仍然不能从其他设备访问localhost,这是一个旁注。这可能是由于apache ports.conf配置为本地服务(127.0.0.1),而不是外部服务。
检查以下内容(适用于ubuntu apache2)
$ cat /etc/apache2/ports.conf
如果设置如下:
NameVirtualHost *:80
Listen 127.0.0.1:80
然后将其更改回默认值
NameVirtualHost *:80
Listen 80
假设两台机器都在同一个工作组中,在要连接的机器上打开cmd.exe,键入ipconfig,并在IPv4地址行中注明IP地址。
然后,在要连接的机器上使用
http://{the IP of the target machine}:{port number}
例如http://192.168.0.1:80,如果你的网站运行在端口80。
这样就行了。
要在两台笔记本电脑上进行测试,你可以使用http://localhost.run/或https://ngrok.com/这样的服务
如果你在Windows上,使用ipconfig获取本地IPv4地址,然后在Apache配置文件:httpd.conf下指定该地址,如下所示:
Listen: 10.20.30.40:80
重新启动Apache服务器并从网络上的其他计算机上测试它。
推荐文章
- 如何从同一网络上的另一台计算机连接到此本地主机?
- 127.0.0.1和localhost之间的区别是什么
- 如何允许本地主机上的Apache使用HTTPS ?
- OAuth:如何测试本地url ?
- 为跨源请求设置cookie
- 在Ansible主机上执行命令
- 从Android模拟器访问localhost:端口
- 你能在本地主机地址上测试谷歌分析吗?
- 当ngrok试图连接到React开发服务器时,主机头无效
- 如何在Android模拟器中连接本地主机?
- 如何从iPhone浏览器访问本地主机上运行的网站
- 在MacOS上的Chrome中,NET::ERR_CERT_INVALID上没有“Proceed Anyway”选项
- 在本地主机上使用reCAPTCHA
- 如何从Android模拟器连接到我的http://localhost web服务器
- 从VirtualBox虚拟机寻址localhost