【问题标题】:Access local apache virtualhost on Android (same network)访问 Android 上的本地 apache 虚拟主机(同一网络)
【发布时间】:2016-04-27 18:15:18
【问题描述】:

我有一台电脑和一台 S3 在同一个 wifi 网络上,这台电脑有 apache 与 VirtualHost 一起为http://example.local 运行,还有一些其他的。这一切都可以在计算机上正常工作。电脑IP为10.0.0.2

手机已root,我将10.0.0.2 example.local www.example.local 附加到/system/etc/hosts 后,即使ping 正常,它也找不到域。我对此尝试了一些 SO 解决方案,但没有解决它,所以我删除了默认的 hosts 文件并将顶行保留为我的 10.0.0.2 定义。这现在在浏览器中连接到我的机器,但它只加载 localhost vhost 配置,而不是 example.local 配置。

httpd-vhosts.conf在电脑上

<VirtualHost localhost:80>
    ServerAdmin tom.corby@tastecard.co.uk
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ErrorLog "logs/error.log"
    CustomLog "logs/access.log" common
</VirtualHost>

<VirtualHost www.example.local:80>
    ServerAdmin tom.corby@tastecard.co.uk
    DocumentRoot "C:/xampp/htdocs/www.example.co.uk/branches/release/3.4/www/"
    ServerName www.example.local
    ServerAlias example.local
    ErrorLog "logs/www.example.local.log"
    CustomLog "logs/www.example.local.log" common

    <Directory "C:/xampp/htdocs/www.example.co.uk/branches/release/3.4/www/">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

就像我说的那样,这可以在计算机上正常加载,我可以为我的 xampp/htdocs 目录加载 localhost,或者为更深的项目目录加载 example.local。我在android上得到的只是localhost目录

【问题讨论】:

    标签: android apache virtualhost vhosts hosts


    【解决方案1】:

    VirtualHost 配置不正确,所以它默认回到默认的localhost vhost(这可能是为什么 URL 在 SO 上显示为红色的原因?真的应该是对我的警告)

    不要在 &lt;VirtualHost&gt; 元素中定义 URL,只需将其保留为 *:80 即可。不知道为什么电脑没问题,但安卓不行。

    【讨论】:

      猜你喜欢
      • 2012-08-04
      • 2021-05-14
      • 1970-01-01
      • 2023-03-29
      • 2011-05-13
      • 2012-02-16
      • 2018-06-26
      • 2017-12-20
      • 2011-10-31
      相关资源
      最近更新 更多