设置 WAMP 在 LAN 上运行,包括移动访问、iPhone

发布于 2024-11-19 20:02:21 字数 524 浏览 3 评论 0原文

我正在 Win 7 上使用 WampServer v2.0 开发 CodeIgniter 应用程序 - 我已经编辑了本地 HOSTS 文件,以便可以在此处访问它: ht_tp://测试域/ 而不是 ht_tp://localhost/testdomain/ 帮助使其在本地工作与实时部署时相同,使用如下行: 127.0.0.1 testdomain

当我在同一台电脑上的浏览器中访问页面时,此设置工作正常。

现在我正在开发一些供移动使用的新页面,例如iPhone,我希望能够直接在iPhone 上查看我的网站。手机已连接到局域网,并且我在PC上开放了80端口。

我希望能够在 iPhone 上访问 ht_tp://testdomain/,但它告诉我找不到服务器。

// 编辑 - 我需要的额外部分是我需要能够同时在本地主机上运行多个站点,并且它们都从根开始工作 - 这就是我想使用 testdomain/ 的原因。

我现在不知道要谷歌什么,有人可以帮我吗?

谢谢, Dan

(ht_tp 表示 http,以防不明显)

I'm developing a CodeIgniter app on Win 7, using WampServer v2.0 - I've edited my local HOSTS file so that I can access it here:
ht_tp://testdomain/
instead of
ht_tp://localhost/testdomain/
to help make it work the same locally as it does when deployed live, with a line like this:
127.0.0.1 testdomain

This set up is working fine when I access the pages in browser on the same PC.

Now I'm developing some new pages for mobile use, e.g. iPhone, and I want to be able to view my site directly on the iPhone. The phone is connected to the LAN, and I've opened up port 80 on the PC.

I want to be able to go to ht_tp://testdomain/ on the iphone, but it tells me it can't find the server.

// edit - an extra part I need is that I need to be able to run more than one site on my localhost at the same time, and they all work from the root - this is why I wanted to use testdomain/.

I'm not sure what to Google for now, can someone help me out?

Thanks,
Dan

(ht_tp means http in case that wasn't obvious)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

冷情妓 2024-11-26 20:02:21

好的,这就是我们在这里解决的方法,它可以很好地满足我的要求。简而言之,它为私有请求开放端口 80,并配置 apache 来处理请求。每个站点在 LAN 中都有自己的 IP 地址。然后 iPhone 和其他计算机就可以访问您的计算机托管的网页。
如果您在 80 以外的端口上运行 Apache,请使用该端口号。

要在 Windows 7 上打开端口 80

转到控制面板 ->系统与安全-> Windows 防火墙
打开高级配置并打开入站规则,创建新规则。
选择“端口”,单击“下一步”,选择 TCP 并输入 80 作为端口,单击“下一步”。
选择“允许连接”并单击下一步。
仅选中“专用”框,清除“域”和“公共”框。单击“下一步”。
给它一个名称和描述,在这里我添加了一条注释,表明我制定此规则是为了帮助提醒我它将来的用途。
确定所有这些并退出窗口。

我的 LAN IP 地址是什么?

现在您需要知道您的主机计算机的 IP 是什么,并且它必须是静态的。我了解这取决于您的路由器,因此如果需要,请检查您的路由器管理员。
要获取您的 IP 地址,请打开命令行,

ipconfig /all

在输出中向上滚动并找到显示地址 IPv4 的行 - 这应该说明您的 LAN IP 地址,例如 192.168.2.100 - 记下它,关闭命令窗口。

为您的主机分配多个 IP 地址

您需要执行此操作才能从根目录运行多个网站,每个网站在 LAN 上都有自己的 IP 地址。
打开网络和共享中心,您将在活动网络旁边看到本地连接的链接,单击该链接,然后单击弹出窗口中的属性。
单击“Internet 协议版本 4 (TCP/IPv4)”项,然后单击“属性”。
现在选择选项“使用以下IP 地址:”并输入您的IP,例如192.168.2.100。保留默认子网掩码,然后输入 LAN 上路由器的 IP,我的是 192.168.2.1。还要在下表中添加首选 DNS 服务器的 IP。

单击“高级...”。现在,您在此表中再次输入您的 IP 地址,并添加您想要用于托管站点的其他 IP 地址。它们必须是您 LAN 上的空闲 IP。我只需要多一个 IP,而只有 2 台 PC 和一台 iPhone 使用我的网络,所以我只在 IP 中添加了 10 个,即 192.168.2.100 和 192.168.2.110。记下您设置的 IP。
单击“确定”并从弹出窗口中一直保存。

配置 Apache

现在 Apache 需要知道如何处理这些 IP 地址,因此首先找到 httpd.conf 文件,我的文件在这里:

C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf

找到行:

Listen 80

并将其更改为添加您的 IP 地址和端口:

Listen 192.168.2.100:80
Listen 192.168.2.110:80

在此文件中,您需要配置对托管站点的目录的访问权限,如下所示:

<Directory "c:/wamp/www/test_website_aaaaaa/">
  allow from all
</Directory>

<Directory "c:/wamp/www/test_website_bbbbbb/">
  allow from all
</Directory>

保存并关闭文件。现在找到 httpd-vhosts.conf 文件,我的文件在这里:

C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf

这里您需要添加 VirtualHost 指令以将 IP 地址指向您的文件夹,如下所示:

<VirtualHost 192.168.2.110:80>
    DocumentRoot "C:/wamp/www/test_website_aaaaaa"
</VirtualHost>

<VirtualHost 192.168.2.110:80>
    DocumentRoot "C:/wamp/www/test_website_bbbbbb"
</VirtualHost>

保存并关闭文件,然后重新启动 Apache。

您现在应该能够通过 IP 在 iPhone 上访问这些网站,例如
http://192.168.2.110

ok this is how we've worked it out here and it's working fine for my requirements. In a nutshell it's open up port 80 for private requests, and config apache to handle the requests. Each site gets its own IP address within the LAN. Then the iPhone, and other computers, can access the webpages hosted by your computer.
If you're running Apache on a port other than 80, use that number instead.

To open up Port 80 on Windows 7

Go to Control Panel -> System and Security -> Windows Firewall
Open up Advanced Configuration and open Inbound Rules, create a New Rule.
Choose Port, click Next, choose TCP and enter 80 as the port, click Next.
Choose "Allow the connection" and click Next.
Check the Private box only, clear the Domain and Public ones. Click Next.
Give it a name and a description, here I added a note that I'd made this rule to help remind me what it was for in the future.
Ok all of that and exit the window.

What's my LAN IP address?

Now you need to know what the IP is of your hosting computer, and it needs to be static. This depends on your router I understand, so check in your router admin if you need to.
To get your IP address open Command Line, type

ipconfig /all

scroll back up through the output and find the line showing Address IPv4 - this should state your LAN IP address, e.g. 192.168.2.100 - make a note of it, close the Command window.

Assign Multiple IP addresses to your host PC

You need to do this to be able to run more than one website from the root, each site will have its own IP address on the LAN.
Open Network and Sharing Centre, you'll see a link to Local Area Connection next to your active network, click that link, and click on Properties in the popup.
Click the item "Internet Protocol Version 4 (TCP/IPv4)", and then Properties.
Now choose the option "Use the following IP address:" and enter your IP, e.g. 192.168.2.100. Leave the default subnet mask, and then enter the IP of your router on the LAN, mine was 192.168.2.1. Also add that IP for the Preferred DNS Server in the table below.

Click on "Advanced...". Now you enter your IP address again in this table, and also add the other IP addresses you want to use to host your sites. They must be vacant IPs on your LAN. I just needed one more IP, and there are only 2 PCs and one iPhone using my network so I just added 10 to the IP, 192.168.2.100 and 192.168.2.110. Make a note of the IPs you set up.
Click OK and save all the way out of those popups.

Configure Apache

Now Apache needs to know what to do with these IP addresses, so find the httpd.conf file first, mine was here:

C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf

Find the line:

Listen 80

and change it to add your IP addresses with the port:

Listen 192.168.2.100:80
Listen 192.168.2.110:80

Further down in this file you need to configure the access to the directories that host your sites, like this:

<Directory "c:/wamp/www/test_website_aaaaaa/">
  allow from all
</Directory>

<Directory "c:/wamp/www/test_website_bbbbbb/">
  allow from all
</Directory>

Save and close the file. Now find the httpd-vhosts.conf file, mine was here:

C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf

Here you need to add VirtualHost directives to point the IP address at your folders, like this:

<VirtualHost 192.168.2.110:80>
    DocumentRoot "C:/wamp/www/test_website_aaaaaa"
</VirtualHost>

<VirtualHost 192.168.2.110:80>
    DocumentRoot "C:/wamp/www/test_website_bbbbbb"
</VirtualHost>

Save and close the file, and restart Apache.

You should now be able to access those sites on your iPhone via the IPs, e.g.
http://192.168.2.110

白馒头 2024-11-26 20:02:21

我也有同样的问题,现在已经解决了。你要做的就是进入apache,然后进入httpd.confg。将端口设置为 8080 并允许所有访问“允许所有形式”,然后在命令提示符中转到 ipconfig 并查看那里的 ip 形式,并在您的移动浏览器中给出相同的 ip,后跟冒号和端口示例“192.168 .0.2:8080/exmple.php”,您可以在手机上访问您的 php 页面。

well same was the problem with me , now sloved. what u have to do is to go in apache and then httpd.confg. set the port to 8080 and allow all acess to " allow form all" every where and then go to ipconfig in comnd prompt and see ip form there and give the same ip in ur mobile browser which is followed by a colon and port exmple" 192.168.0.2:8080/exmple.php" and u can access ur php page in ur mobile.

岛徒 2024-11-26 20:02:21

Wamp>阿帕奇> httpd.conf

将行更改

Deny from all

Allow from all

Wamp > Apache > httpd.conf

Change the line

Deny from all

to

Allow from all
面如桃花 2024-11-26 20:02:21

对于该问题有一些解决方案 这里

There are a few solutions for that problem to be found here.

困倦 2024-11-26 20:02:21

在 iPad 上,转到 wifi 设置并关闭 http 代理。这对我有用

On your iPad go to you wifi settings and turn Off your http proxy. It worked for me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文