简体   繁体   English

无法使用Easyphp通过Android设备访问localhost

[英]can't access localhost via android device using Easyphp

I'm using Easyphp to host my local website on windows and It works flawlessly. 我正在使用Easyphp在Windows上托管我的本地网站,它运行完美。 Now I'm trying to launch the website from my android phone. 现在我正试图从我的Android手机启动网站。 But It doesn't seem to work by just typing : 但它似乎只通过键入:

http://pclocalip:8080 or http://pclocalip http:// pclocalip:8080http:// pclocalip

As other web hosts like XAMPP and WAMP allow it by just doing that. 正如XAMPPWAMP等其他Web主机允许它一样。

If you are using default android emulator 如果您使用默认的Android模拟器

The first step is to start the AVD with an increased partition size otherwise you may get an out of memory error when you try to save the modified hosts file 第一步是使用增加的分区大小启动AVD,否则当您尝试保存修改后的hosts文件时可能会出现内存不足错误

emulator -avd MyAVD -partition-size 128 模拟器-avd MyAVD -partition-size 128

You then have to remount the system partition so that it is writeable 然后,您必须重新安装系统分区,以便它是可写的

adb remount adb remount

Then copy the hosts file from the emulated device to the host machine 然后将hosts文件从模拟设备复制到主机

adb pull /etc/hosts adb pull / etc / hosts

Edit the hosts file so that it includes mappings for all relevant virtual host names 编辑hosts文件,使其包含所有相关虚拟主机名的映射

127.0.0.1 localhost 127.0.0.1 localhost

10.0.2.2 pclocalip 10.0.2.2 pclocalip

Then copy the updated file back to the emulated device 然后将更新的文件复制回模拟设备

adb push hosts /etc/hosts adb push hosts / etc / hosts

You should then be able to visit http://pclocalip in the emulator's browser and see the correct site 然后,您应该能够在模拟器的浏览器中访问http:// pclocalip并查看正确的站点

PS: Note that 10.0.2.2 here is the localhost IP address of your machine that run the AVD PS:请注意,此处10.0.2.2是运行AVD的计算机的本地主机IP地址

There is a module especially for that : www.easyphp.org/documentation/devserver/mobile-for-devserver.php 特别是有一个模块: www.easyphp.org/documentation/devserver/mobile-for-devserver.php

"With the module "Mobile", you can test your code on your mobile phone / tablet and see if your website / application is mobile friendly." “使用”Mobile“模块,您可以在手机/平板电脑上测试代码,看看您的网站/应用程序是否适合移动设备。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM