php 如何允许远程访问我的 WAMP 服务器(用于移动设备(Android))

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19132059/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:53:03  来源:igfitidea点击:

How to allow remote access to my WAMP server for Mobile(Android)

phpnetworkingwampwireless

提问by

I have created a website for mobile using PHP and jQuery. It works on my PC but now I want to test it with my Android device. How can I do that?

我使用 PHP 和 jQuery 创建了一个移动网站。它适用于我的 PC,但现在我想用我的 Android 设备测试它。我怎样才能做到这一点?

How can I access a WAMP server's IP from my Android device?

如何从我的 Android 设备访问 WAMP 服务器的 IP?

My mobile and PC are connected within the same router. Should I directly connect to my PC or can I do that through the router?

我的手机和PC连接在同一路由器内。我应该直接连接到我的 PC 还是我可以通过路由器连接?

I have searched about it and found that I have to change permissions in phpmyadmin.conf but still it does not work. Any ideas why doesn't it work?

我搜索了它,发现我必须在 phpmyadmin.conf 中更改权限,但它仍然不起作用。任何想法为什么它不起作用?

My httpd.config has something like this.

我的 httpd.config 有这样的东西。

<Directory />
    Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 192.168.0.104
</Directory>

192.168.0.104 is my android device's IP.

192.168.0.104 是我的安卓设备的 IP。

采纳答案by SamV

I assume you are using windows. Open the command prompt and type ipconfigand find out your local address (on your pc) it should look something like 192.168.1.13or 192.168.0.5where the end digit is the one that changes. It should be next to IPv4 Address.

我假设您正在使用 Windows。打开命令提示符并键入ipconfig并找出您的本地地址(在您的 PC 上),它应该类似于192.168.1.13192.168.0.5末尾数字是更改的位置。它应该在 IPv4 地址旁边。

If your WAMP does not use virtual hosts the next step is to enter that IP address on your phones browser ie http://192.168.1.13If you have a virtual host then you will need root to edit the hosts file.

如果您的 WAMP 不使用虚拟主机,下一步是在您的手机浏览器中输入该 IP 地址,即http://192.168.1.13如果您有一个虚拟主机,那么您将需要 root 来编辑主机文件。

If you want to test the responsiveness / mobile design of your website you can change your user agent in chrome or other browsers to mimic a mobile.

如果您想测试您网站的响应能力/移动设计,您可以在 Chrome 或其他浏览器中更改您的用户代理以模拟移动设备。

See http://googlesystem.blogspot.co.uk/2011/12/changing-user-agent-new-google-chrome.html.

请参阅http://googlesystem.blogspot.co.uk/2011/12/changed-user-agent-new-google-chrome.html

Edit: Chrome dev tools now has a mobile debug tool where you can change the size of the viewport, spoof user agents, connections (4G, 3G etc).

编辑:Chrome 开发工具现在有一个移动调试工具,您可以在其中更改视口的大小、欺骗用户代理、连接(4G、3G 等)。

If you get forbidden access then see this question WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server. Basically, change the occurrances of deny,allowto allow,denyin the httpd.conffile. You can access this by the WAMP menu.

如果您被禁止访问,请参阅此问题WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server。基本上,更改文件中deny,allowtoallow,deny的出现httpd.conf。您可以通过 WAMP 菜单访问它。

To eliminate possible causes of the issue for now set your config file to

要暂时消除问题的可能原因,请将您的配置文件设置为

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    <RequireAll>
        Require all granted
    </RequireAll>
</Directory>

As thatis working for my windows PC, if you have the directory config block as well change that also to allow all.

由于这适用于我的 Windows PC,如果您也有目录配置块,也可以更改它以允许所有。

Config file that fixed the problem:

解决问题的配置文件:

https://gist.github.com/samvaughton/6790739

https://gist.github.com/samvaughton/6790739

Problem was that the /www apache directory config block still had deny set as default and only allowed from localhost.

问题是 /www apache 目录配置块仍然将拒绝设置为默认值,并且只允许来自本地主机。