wampserver2.5局域网公网IP访问配置

wampserver2.5集成环境的安装和使用就不多说了,网上有很多教材。安装好后找到apache的配置文件httpd.conf。默认位置是: swap安装目录\wamp\bin\apache\apache2.4.9\conf\httpd.conf

在278行处找到(也可全文搜索)

onlineoffline tag - don't remove

Require local

将此处修改如下

onlineoffline tag - don't remove

Require local

Deny from all

Require all granted

Order Deny,Allow

Allow from 127.0.0.1

Allow from 192.168.1.*

解释如下:用#注释掉原配置的本地请求,添加Require all granted(允许外部访问),有的版本配置文件会有 Deny form all(禁止访问) 也注释掉,没有就不用管。Allow from 127.0.0.1 (允许本地访问,Windows一般本地主机IP为127.0.0.1可在host文件里查看)。Allow from 192.168.1.(允许局域网访问,一般局域网默认网关为192.168.1.,具体根据本地路由器配置决定。也可以将

Allow from 127.0.0.1

Allow from 192.168.1.*

换成

Allow from all

(允许全部访问)。

所有的请求都被拒绝

2.2上的配置

Order deny,allow
Deny from all

2.4上的配置

Require all denied

所有请求都是允许的

2.2上的配置

Order allow,deny
Allow from all

2.4上的配置

Require all granted

在域中的所有主机都可以访问example,所有其他外网主机的访问被拒绝

2.2上的配置

Order Deny,Allow
Deny from all
Allow from example.org

2.4上的配置

Require host example.org

要想外网访问将 Require local 该为 Require all granted 。

经常会用到的:
Require all denied
Require all granted
Require host xxx.com
Require ip 192.168.1 192.168.2
Require local

举例说明

仅允许IP:192.168.0.1 访问

Require all granted
Require ip 192.168.0.1

仅禁止IP:192.168.0.1访问

Require all granted
Require not ip 192.168.0.1

允许所有访问

Require all granted

拒绝所有访问

Require all denied

默认是 Require local 仅允许本地访问。

还有好多变化,可以去官方说明详细看一下,不过只有英文版的。软件变化无常,建议大家升级前详细阅读官方更新文档,以免来个措手不及。

猜你喜欢

转载自www.cnblogs.com/xiedong2016/p/11031323.html