WampServer3.0.6配置允许外网访问

安装并配置好WampServer 3.0.6之后,在本机上使用http://localhost或者http://127.0.0.1访问一切OK,但是使用局域网IP访问不正常,出现如下提示:

1、更改httpd.conf中的244行附近的 <Directory />,把Require all denied更改为Require all granted

<Directory />
    AllowOverride none
    Require all denied    
 </Directory>

把Require all denied更改为Require all granted

<Directory />
    AllowOverride none
    #Require all denied
    Require all granted
 </Directory>

2、查找httpd.conf中的263行附近的DocumentRoot,在第291行附近Require local后面新增一行Require all granted

DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/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.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks +Multiviews

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Require local
    Require all granted
</Directory>

扫描二维码关注公众号,回复: 2334424 查看本文章

如果按照WampServer之前的版本,重启apache后应该能从外网访问了,之后发现还是访问不了:

仍旧访问不了

Why?这是由于WampServer3.0.6的apache版本为2.4.23

原来在apache 2.4.23中有这段代码:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

这样导致httpd.conf中的单独设置的Require all granted不起作用,还需要对apache根目录\conf\extra\httpd-vhosts.conf文件中的进一步配置。

3、在httpd-vhosts.conf在Directory 中添加:Require all granted

在httpd-vhosts.conf文件修改配置,增加一行Require all granted:

# Virtual Hosts
#
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot c:/wamp64/www
    <Directory  "c:/wamp64/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
        Require all granted
    </Directory>
</VirtualHost>

至此,外网访问一切正常了!

猜你喜欢

转载自blog.csdn.net/xieyunc/article/details/81167022