如何在没有互联网连接的情况下通过局域网访问运行 apache 服务器的站点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/857774/
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
How to access site running apache server over lan without internet connection
提问by duckyflip
I am running a server on Windows XP SP2 computer using EasyPhp. Lets call it computer_1. The ip address of computer is 192.168.1.2
我正在使用 EasyPhp 在 Windows XP SP2 计算机上运行服务器。让我们称之为computer_1。电脑的ip地址是192.168.1.2
Now I have another computer ( computer_2) on the lan with ip address 192.168.1.3
现在我在局域网上有另一台计算机(computer_2),IP 地址为 192.168.1.3
I want to access the site on computer_1 from computer_2.
我想从计算机_2 访问计算机_1 上的站点。
comupter_2 can ping computer_1 (ping 192.168.1.2 works)
电脑_2可以ping电脑_1(ping 192.168.1.2有效)
But when I type http://192.168.1.2in the browser of computer_2, nothing happens.
但是当我 在 computer_2 的浏览器中输入http://192.168.1.2时,没有任何反应。
I want to access the site on comupter_1 from computer_2.
我想从 computer_2 访问 comupter_1 上的站点。
回答by duckyflip
In your httpd.confmake sure you have:
在你httpd.conf确保你有:
Listen *:80
And if you are using VirtualHosts then set them as given below:
如果您使用的是 VirtualHosts,则将它们设置如下:
NameVirtualHost *
<VirtualHost *>
...
</VirtualHost>
回答by Fadzly Othman
Open httpd.conf of Apache server (backup first) Look for the the following : Listen
打开Apache服务器的httpd.conf(先备份)查找以下内容:Listen
Change the line to
将行更改为
Listen *:80
Still in httpd.conf, look for the following (or similar):
仍然在 httpd.conf 中,查找以下(或类似内容):
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
Deny from all
</Directory>
Change this block to :
将此块更改为:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
#Deny from all
</Directory>
Save httpd.conf and restart apache
保存 httpd.conf 并重启 apache
Open port 80 of the server such that everyone can access your server.
打开服务器的 80 端口,以便每个人都可以访问您的服务器。
Open Control Panel >> System and Security >> Windows Firewall then click on “Advance Setting” and then select “Inbound Rules” from the left panel and then click on “Add Rule…”. Select “PORT” as an option from the list and then in the next screen select “TCP” protocol and enter port number “80” under “Specific local port” then click on the ”Next” button and select “Allow the Connection” and then give the general name and description to this port and click Done.
打开控制面板>>系统和安全>>Windows防火墙,然后单击“高级设置”,然后从左侧面板中选择“入站规则”,然后单击“添加规则...”。从列表中选择“端口”作为选项,然后在下一个屏幕中选择“TCP”协议并在“特定本地端口”下输入端口号“80”,然后单击“下一步”按钮并选择“允许连接”和然后为此端口提供通用名称和描述,然后单击“完成”。
Restart WAMP and access your machine in LAN or WAN.
重新启动 WAMP 并在 LAN 或 WAN 中访问您的机器。
回答by Hardik Thaker
*Don't change anything to Listen : keep it as it is..
*不要改变任何东西来听:保持原样..
1) Open httpd.conf of Apache server (backup first) Look for the the following :
1)打开Apache服务器的httpd.conf(先备份)查找以下内容:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
#Deny from all
</Directory>
and also this
还有这个
<Directory "cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
2) Now From taskbar :
2)现在从任务栏:
Click on wamp icon > Apache > Apache modules > apache_rewrite (enable this module)
单击 wamp 图标 > Apache > Apache 模块 > apache_rewrite(启用此模块)
And Ya Also Activate "Put Online" From same taskbar icon
和 Ya 还从同一个任务栏图标激活“Put Online”
You need to allow port request from windows firewall setting.
您需要允许来自 Windows 防火墙设置的端口请求。
(Windows 7)
(Windows 7的)
Go to control panel > windows firewall > advance setting (on left sidebar)
转到控制面板 > Windows 防火墙 > 高级设置(在左侧边栏上)
then
然后
Right click on inbound rules -> add new rule -> port -> TCP (Specific port 80 - if your localhost wok on this port) -> Allow the connections -> Give a profile name -> ok
右键单击入站规则 -> 添加新规则 -> 端口 -> TCP(特定端口 80 - 如果您的本地主机在此端口上工作) -> 允许连接 -> 提供配置文件名称 -> 确定
Now Restart all the services of Apache server & you are done..
现在重启Apache服务器的所有服务,你就完成了..
回答by Nassim
if you did change the httpd.conffile located under conf_filesfolder, don't use windows notepad, you need a unix text editor, try TED pad, after making any changes to your httpd.conf file save it. ps: if you use a dos/windows editor you will end up with an "Error in Apache file changed"message. so do be careful.... Salam
如果您确实更改了conf_files文件夹下的httpd.conf文件,请不要使用 windows 记事本,您需要一个 unix 文本编辑器,尝试TED pad,在对 httpd.conf 文件进行任何更改后保存它。ps:如果您使用 dos/windows 编辑器,您最终会收到“Apache 文件更改错误”消息。所以一定要小心...... Salam
回答by Pratik Dangol
nothing to be done for running your wamp sites to another computer. 1. first turn off the firewall. 2. Set Put Online in wamp by clcking in wamp icon at near to clock.
无需将您的 wamp 站点运行到另一台计算机上。1.首先关闭防火墙。2. 通过在时钟附近的 wamp 图标中单击来在 wamp 中设置在线。
Finally run your browser in another computer and type http:\ip address or computer name e.g. http:\192.168.1.100
最后在另一台计算机上运行浏览器并输入 http:\ip 地址或计算机名称,例如 http:\192.168.1.100
回答by Surjeet Verma
Your firewall does not allow any new connection to share information without your consent. ONLY thing to do is give your consent to your firewall.
未经您的同意,您的防火墙不允许任何新连接共享信息。唯一要做的就是同意您的防火墙。
Go to Firewall settings in Control Panel
Click on Advanced Settings
Click on Inbound Rules and Add a new rule.
Choose 'Type Of Rule' to Port.
Allow this for All Programs.
Allow this rule to be applied on all Profiles i.e. Domain, Private, Public.
Give this rule any name.
进入控制面板中的防火墙设置
点击高级设置
单击入站规则并添加新规则。
选择“规则类型”来移植。
允许所有程序使用此功能。
允许将此规则应用于所有配置文件,即域、私有、公共。
给这个规则任何名称。
That's it. Now another PC and mobiles connected on the same network can access the local sites. Lets Start Development.
就是这样。现在连接在同一网络上的另一台 PC 和手机可以访问本地站点。让我们开始开发。
回答by sleske
Please reformulate your question. Your first sentence does not make sense.
.
请重新表述您的问题。你的第一句话没有意义。
.
To address your question:
要解决您的问题:
http://ip.of.server/should work in principle. However, depending on configuration (virtual hosting) only using the correct host name may work.
http://ip.of.server/原则上应该可以工作。但是,根据配置(虚拟主机),仅使用正确的主机名可能会起作用。
At any rate, if you have a network, you should properly configure DNS, otherwise all kinds of problems (such as this) may occur.
无论如何,如果你有网络,你应该正确配置DNS,否则可能会出现各种问题(比如这个)。
回答by Eric Petroelje
You might also want to check your server configuration - sometimes the default for development type servers is to only accept connections from localhost.
您可能还想检查您的服务器配置 - 有时开发类型服务器的默认设置是只接受来自本地主机的连接。
回答by user2388935
- navigate to C:\wamp\alias.
- make file with project name and like phpmyadmin.conf
add the following section and change :
Options Indexes FollowSymLinks MultiViews AllowOverride all Order Deny,Allow Allow from all
- 导航到 C:\wamp\alias。
- 使用项目名称制作文件,例如 phpmyadmin.conf
添加以下部分并更改:
选项索引 FollowSymLinks MultiViews AllowOverride all Order Deny, Allow Allow from all
change directory to your directory path like c:\wamp\www\projectfolder
将目录更改为您的目录路径,如 c:\wamp\www\projectfolder
make sure you make the same in httpd.conf for all directory like first directory:
Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all
确保在 httpd.conf 中为所有目录(如第一个目录)设置相同的内容:
选项索引 FollowSymLinks AllowOverride All Order allow,deny Allow from all
second directory:
第二个目录:
<Directory "c:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.0/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Allow from all
</Directory>
<Directory "icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
回答by Sandeep Gaadhe
I was trying to access my localhost website (on my pc) from my mobile (andriod). The configuration is like Windows 10, WAMP 2.4.23, PHP Website and my mobile was running on andriod. Both my mobile and pc are connected to same wifi.
我试图从我的手机(andriod)访问我的本地主机网站(在我的电脑上)。配置类似于 Windows 10、WAMP 2.4.23、PHP 网站,我的手机在 Android 上运行。我的手机和电脑都连接到同一个wifi。
I was able to open my website on my pc by using url http://localhost/mysiteor http://127.0.0.1/mysite. My pc ip was 192.168.0.1 (say) and my mobile ip was 192.168.0.2 (say) and both connected on same wifi.
我可以使用 url http://localhost/mysite或http://127.0.0.1/mysite在我的电脑上打开我的网站。我的电脑 ip 是 192.168.0.1(比如说),我的移动 ip 是 192.168.0.2(比如说)并且都连接在同一个 wifi 上。
I tried all the setting like changing the httpd.conf, httpd-vhosts.conf only to find that all I need was to disable my firewall. Of course, disabling the firewall completely is not a good idea. I have avast antivirus running on my pc. If I check the firewall log for last one hour (or so) I can see that attempt has been made by my mobile ip to connect to website running on my pc. All it required was to add an exception by creating a new rule in avast UI which will allow connections from my mobile ip.
我尝试了所有设置,如更改 httpd.conf、httpd-vhosts.conf 只是发现我需要的只是禁用我的防火墙。当然,完全禁用防火墙并不是一个好主意。我的电脑上运行着 avast 杀毒软件。如果我检查过去一小时(左右)的防火墙日志,我可以看到我的移动 IP 已尝试连接到我的 PC 上运行的网站。它所需要的只是通过在 avast UI 中创建一个新规则来添加一个例外,该规则将允许来自我的移动 IP 的连接。
Hope this helps someone.
希望这可以帮助某人。

