且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-02-21 23:16:38

好的,这就是我们在这里进行的工作,并且可以很好地满足我的要求.简而言之,它开放了端口80来处理私人请求,并配置apache来处理请求.每个站点在局域网内都有自己的IP地址.然后,iPhone和其他计算机可以访问计算机托管的网页. 如果您在80以外的端口上运行Apache,请改用该数字.

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.

要在Windows 7上打开端口80

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

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.

我的LAN IP地址是什么?

现在,您需要知道主机计算机的IP,并且该IP必须是静态的.这取决于您了解的路由器,因此,如果需要,请签入路由器管理员. 要获取IP地址,请打开命令行,输入

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

滚动查看输出,找到显示地址IPv4的行-这应该说明您的LAN IP地址,例如192.168.2.100-记下它,关闭命令"窗口.

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.

为主机分配多个IP地址

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

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.

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

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.

配置Apache

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

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

查找行:

Listen 80

并对其进行更改,以使用以下端口添加您的IP地址:

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>

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

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

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

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>

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

Save and close the file, and restart Apache.

您现在应该可以通过IP(例如, http://192.168.2.110

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