zoukankan      html  css  js  c++  java
  • Apache: You don't have permission to access / on this server

    当我们需要使用Apache配置虚拟主机时,有可能会出现这个问题:Apache: You don't have permission to access / on this server

    # 同IP不同域名
    # Listen for virtual host requests on all IP addresses
    NameVirtualHost *:8080
    
    <VirtualHost *:8080>
    DocumentRoot "D:/lamp/phpweb/full"
    ServerName full.thinkphp.com
    </VirtualHost>
    
    <VirtualHost *:8080>
    DocumentRoot "D:/lamp/core"
    ServerName core.thinkphp.com
    # Other directives here
    </VirtualHost>
    
    <Directory "D:/lamp/core">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    我们使用上面的配置来实现基于不同域名的多站点配置,如果我不添加最后一段红色字体的部分,就会出现上面的问题,因为这部分的意思是

    #
    # Each directory to which Apache has access can be configured with respect
    # to which services and features are allowed and/or disabled in that
    # directory (and its subdirectories). 
    #
    # First, we configure the "default" to be a very restrictive set of 
    # features.  
    #
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>

    这是Apache配置文件中的一段,大概意思就是'每一个Apache有权限访问的目录都需要配置,指定那个目录下的哪个服务是被允许的或者不被允许的',而默认是不能被访问的。

    这里就找到了上面那个问题的原因了,如果我没有添加那段红色的字体部分,就表示,那个目录是不被允许访问的,所以就出现403错误。

    注意:为什么第一个域名就不需要配置,那是因为,它放在'ServerRoot'目录下,所以是允许访问的。而第二个目录不在'ServerRoot'目录下,所以需要另外指定它允许的权限。

  • 相关阅读:
    [树形DP]Luogu P1131 [ZJOI2007]时态同步
    [状压DP]JZOJ 1303 骑士
    [DFS]JZOJ 1301 treecut
    [最小费用最大流]JZOJ 4802 探险计划
    [KMP][倍增求LCA]JZOJ 4669 弄提纲
    [DP]JZOJ 1758 过河
    列表生成式和生成器表达式
    协程函数
    生成器
    迭代器
  • 原文地址:https://www.cnblogs.com/lit10050528/p/4273844.html
Copyright © 2011-2022 走看看