简体   繁体   English

通过android从USB通过笔记本电脑localhost访问网站(无WiFi)

[英]Access website on laptop localhost over USB, from android (NO WiFi)

I have Firefox on the laptop using Debian, Firefox on the phone (Android-not rooted), I want to use the USB to access the wordpress website I have locally on the laptop. 我在使用Debian的笔记本电脑上安装了Firefox,在手机上安装了Firefox(Android系统未植根),我想使用USB来访问我在笔记本电脑上本地拥有的wordpress网站。 I want to be able to type in Firefox on android: http://localhost/mywebsite , or static-IP/mywebsite. 我希望能够在android上输入Firefox: http:// localhost / mywebsite或static-IP / mywebsite。

I can see my device connected when I type in terminal: adb devices. 当我输入终端:adb devices时,我可以看到设备已连接。 I tried 127.0.0.1, I tried 10.0.2.2, I'm reading all kind of tips, but nothing clear using ONLY USB connection (no wifi or wired). 我尝试了127.0.0.1,我尝试了10.0.2.2,正在阅读各种技巧,但仅使用USB连接(没有wifi或有线)无法清除所有提示。

On Chrome seems to be very simple with (reverse) port forwarding: https://developer.chrome.com/devtools/docs/remote-debugging?hl=de#port-forwarding 在Chrome上,使用(反向)端口转发似乎非常简单: https//developer.chrome.com/devtools/docs/remote-debugging?hl = de# port-forwarding

Found the answer, here are the steps I found it work ( no wifi connection ): 找到了答案,这是我发现它可行的步骤( 无wifi连接 ):

Connect phone to laptop using USB 使用USB将手机连接到笔记本电脑

  1. On the phone enable in: 在电话上启用:

a) Developer Options: "Android debugging" and "ADB over network" a)开发人员选项:“ Android调试”和“网络ADB”

b) Settings > ...More > Tethering > USB tethering b)设置> ...更多>网络共享> USB网络共享

  1. On the laptop: 在笔记本电脑上:

a) find your new ip in terminal with the command: ip addr (should be something like: 192.168.xx.x). a)使用以下命令在终端中找到新的IP: ip addr (应为:192.168.xx.x)。 Then go back to the phone's browser and visit your website at: 192.168.xx.x/mywebsite 然后返回手机的浏览器并访问您的网站,网址为:192.168.xx.x / mywebsite

b) make sure you local server is running b)确保本地服务器正在运行

c) in terminal verify if your phone is connected by typing: adb devices c)在终端中,通过键入以下命令验证您的电话是否已连接: adb devices

d) forward the port you find in the phone at "ADB over network" (mine is 5555), by typing the command: adb forward tcp:5555 localfilesystem:/data/data/org.mozilla.firefox/firefox-debugger-socket d)通过键入以下命令来转发您在“网络上的ADB”中在电话中找到的端口(我的电话是5555): adb forward tcp:5555 localfilesystem:/data/data/org.mozilla.firefox/firefox-debugger-socket

e) in Firefox go to Developer > Connect and type in "host" the numbers before the colon and in "port", the ones after the colon (mine: 0.0.0.0:5555). e)在Firefox中,转到“开发人员”>“连接”,然后在冒号前键入“主机”,在冒号后键入“端口”(最小值:0.0.0.0:5555)。 Then hit "Connect" and go to the browser on the phone to hit OK for accepting the connection 然后点击“连接”并转到手机上的浏览器,点击确定以接受连接

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

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