我知道很多次都会问过这个问题
我跟随互联网上的大多数答案但我仍然得到相同的消息
403 Forbidden
您无权访问此服务器上的/。
奇怪的是,当我使用同一台PC访问 localhost:1234
时,它正常运行,但如果我使用我的IP地址 192.168.0.188:1234
还有一点非常奇怪,我尝试在其他PC上安装WAMP,没有任何配置,我可以访问该PC。
所以我认为这是因为迈克菲和防火墙让我在Widows和McAfee上打开端口而且没有任何改变,我也关闭了防火墙,但仍然没有任何变化。
然后我无缘无故地通过路由器“端口转发”打开端口,但仍然没有改变。
我认为这不是因为我在WAMP中的配置,因为我仍然能够获得此403 Forbidden
消息,并且使用其他没有任何配置的PC我也可以访问它。
两台PC的设置如下:
Windows 8 Pro
可访问的PC使用 Microsoft Security Essentials 。
无法访问的PC使用 McAfee Internet Security 。
我尝试将关闭WAMP 和启动IIS 对于Microsoft Server(我可以在任何PC上完美运行)但是WAMP仍然无法正常工作
我遵循了这些教程:
Stack Overflow在这里回答:
答案 0 :(得分:117)
默认情况下,Wampserver配置为尽可能安全,因此Apache设置为仅允许从运行wamp的计算机进行访问。毕竟它应该是一个开发服务器而不是一个实时服务器。
此外,WAMPServer 2.4发布了一个小错误,它使用旧的Apache 2.2语法而不是新的Apache 2.4语法来访问权限。
您需要更改Apache上的安全设置以允许从其他任何位置进行访问,因此请编辑httpd.conf
文件。
更改此部分:
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
致:
# onlineoffline tag - don't remove
Require local
Require ip 192.168.0
Require local
允许从这些IP 127.0.0.1 & localhost & ::1
进行访问。
语句Require ip 192.168.0
将允许您从内部网络上的任何IP访问Apache服务器。此外,它还允许使用服务器机器从服务器计算机访问实际的IP地址,正如您尝试的那样。
在版本3和>中WAMPServer有一个为localhost
预先定义的虚拟主机,因此您必须在虚拟主机定义配置文件中进行访问权限安全性
首先不要修改httpd.conf
文件,保留原样。
使用菜单编辑httpd-vhosts.conf
文件。
它应该是这样的:
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
将其修改为
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
希望您已为项目创建虚拟主机,而不是使用您网站的wamp\www
文件夹。在这种情况下,请单独保留localhost定义,并仅对您的虚拟主机进行更改。
不要忘记在进行此更改后重启Apache
答案 1 :(得分:25)
对于Apache 2.4.9
另外,请查看C:\ wamp \ bin \ apache \ apache2.4.9 \ conf \ extra
中的 httpd-vhosts.conf 文件<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot C:/wamp/www
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require local
</Directory>
</VirtualHost>
更改为:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot C:/wamp/www
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
从“需要本地”更改为“需要全部授予”解决了我本地网络中的错误403
答案 2 :(得分:16)
答案 3 :(得分:9)
要扩展RiggsFolly的答案 - 或者对于遇到相同问题但正在使用Apache 2.2或更低版本的任何人 - 这种格式应运行良好:
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
Allow from localhost
Allow from 192.168
Allow from 10
Satisfy Any
有关Apache 2.4格式更改的更多详细信息,官方Upgrading to 2.2 from 2.4页面非常明确&amp;简洁。关键点是:
旧的访问控制习语应该被新的替换 身份验证机制,虽然与旧的兼容 配置,提供了新模块
mod_access_compat
。
这意味着,世界各地的系统管理员不一定要担心将Apache 2.2配置更改为2.4兼容。
答案 4 :(得分:0)
对于那些可能在Windows 10(64位)上使用Apache 2.4.35运行WAMP 3.1.4的用户
如果外部设备连接到本地主机时遇到问题,并收到403 Forbidden错误,则可能是 httpd.conf 和 httpd-vhosts的问题。 conf 文件和它们都包含在其中的“ Require local”行。
[之前] httpd.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local <--- This is the offending line.
</Directory>
</VirtualHost>
[之后] httpd.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
此外,您需要按以下方式更新 httpd.conf 文件:
[之前] httpd.conf
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
# onlineoffline tag - don't remove
Require local #<--- This is the offending line.
</Directory>
[After] httpd.conf
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
# onlineoffline tag - don't remove
# Require local
</Directory>
确保通过(屏幕右下角的系统托盘->左键单击WAMP图标->“重新启动所有服务”)重新启动WAMP服务器。
然后在localhost上刷新计算机的浏览器,以确保在那里仍然具有正确的连接,然后刷新以前尝试连接的其他外部设备。
免责声明::如果您处于公司环境中,则从安全性角度出发未经测试;在实施任何全面的更改之前,请确保您敏锐地意识到本地开发环境的访问协议。