php多站点配置以及Forbidden You don't have permission to access / on this server问题解决

来源:互联网 发布:数据存储服务器 编辑:程序博客网 时间:2024/05/16 18:37

前几天在电脑上配置多站点的后突然出现了:”You don’t have permission to access / on this server!“ 究其原因是:swampserver默认访问的是www文件夹的站点,不允许访问其他的站点。花了老半天的时间解决了。分享一下希望帮助需要的人

first:首先教你如何配置多站点

  1. 在”C:\wamp\bin\apache\apache2.4.9\conf“目录下打开httpd.conf配置文件
    大概516行左右在找到
    # Virtual hosts
    #Include conf/extra/httpd-vhosts.conf
    把include 的注释去掉,让他去加载conf/extra/httpd-vhosts.conf文件

  2. 在”C:\wamp\bin\apache\apache2.4.9\conf\extra“目录打开
    httpd-vhosts.conf文件,直接在这里配置站点
    上面全部注释,第一句
    NameVirtualHost *:80(设置端口号)
    # #以下是自己配置的站点1
    < VirtualHost *:80 >
    ServerName www.xiaozheng.com (网站的域名)
    DocumentRoot “C:\wamp\www” (文件的路径)
    < Directory “C:\wamp\www” > (文件的路径)
    Options Indexes
    Order allow,deny
    Allow from all
    Satisfy all
    < /Directory >
    < /VirtualHost >

    3.在“C:\Windows\System32\drivers\etc”的hosts文件里面配置
    就可以了

但是昨天我在这样子配置的时候出现了一个问题~~如果说我的文件路径在wamp\www以外的话,比如“F:\xiaozheng”会出现“You don’t have permission to access / on this server!”问腿!接下来教你如何解决这个问题

首先:swampserver服务器默认是只能访问站内的文件夹,在http.conf文件里面有
< Directory />
AllowOverride all
Require all denied (拒绝了外部的访问)
< /Directory >
必须把上面的改成:
< Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
#Deny from all
Allow from all
#允许所有访问
Satisfy all
< /Directory>

第二步:
< Directory “D:/Wamp5/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.2/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 removeOrder Deny,AllowDeny from allAllow from 127.0.0.1

< /Directory>

修改成

< Directory “D:/Wamp5/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.2/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 removeOrder Deny,Allow#Deny from all# Allow from 127.0.0.1Allow from all

< /Directory>

其实是可以把一些不必要的注释删掉的,我是把那些注释删掉了,简洁了好多,配图
这里写图片描述

或者还有一种新的解决方法,在httpd-vhosts.conf配置站点的时候这样配置
< VirtualHost *:80 >
ServerName www.xiaozheng.com
DocumentRoot “C:\wamp\www”

<Directory "C:\wamp\www">    Options Indexes FollowSymLinks   #原先是Options Indexes    AllowOverride all                #原先是没有这句的,这两句不管是否超出先限制的文件                                     范围,都可以访问,就不会出现权限问题了    Order allow,deny    Allow from all      Satisfy all</Directory>

< /VirtualHost>

然后保存,重启服务,在访问就解决了这个问题。

希望对新手有帮助

2 0
原创粉丝点击