我目前正在做一个项目,我想在家里的两台笔记本电脑上进行测试,其中一台笔记本电脑连接到另一台本地主机。我正在使用XAMPP。我怎么做呢?


当前回答

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或后面的任意随机数

其他回答

要在两台笔记本电脑上进行测试,你可以使用http://localhost.run/或https://ngrok.com/这样的服务

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。

这样就行了。

如果你在Windows上,使用ipconfig获取本地IPv4地址,然后在Apache配置文件:httpd.conf下指定该地址,如下所示:

Listen: 10.20.30.40:80

重新启动Apache服务器并从网络上的其他计算机上测试它。