【问题标题】:Error 403 after adding virtualhost添加虚拟主机后出现错误 403
【发布时间】:2015-05-23 15:32:04
【问题描述】:

这是我在 /etc/httpd/conf/extra/httpd-vhosts.conf 中的指令

<VirtualHost *:80>
    ServerName sub.somedomain.com
    DocumentRoot "srv/http/subdir"
        <Directory '/srv/http/subdir'>
                Options -Indexes +FollowSymlinks
                AllowOverride All
                Order allow,deny
                Allow from all
                Require all granted
        </Directory>

</VirtualHost>

当我尝试访问 subdir 中的任何文件时,我得到 403 access denied 错误。我重新启动了 apache,我也将 /srv/http 中所有文件的所有权更改为 http:http。

【问题讨论】:

    标签: apache


    【解决方案1】:

    您不需要 options 指令,因为您已经声明了文档根目录。我会删除整个块。您需要声明默认文件。喜欢:
    DirectoryIndex index.html index.php default.html

    另外,请检查您的站点日志或 apache 日志以查看更详细的错误。

    这是我的一个虚拟目录的示例:

        ServerAdmin somememail@gmail.com
        DocumentRoot /var/www/html/directoryname
        ServerName yoursite.com
        ServerAlias www.yoursite.com 
    
    
        #ErrorLog ${APACHE_LOG_DIR}/error.log
        #CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        DirectoryIndex index.html index.php
    

    【讨论】:

    • 您可以取消注释错误日志部分并将其设置为您自己的位置。
    • 您可以通过在您的网址中实际命名您尝试点击的文件名来确定上述内容是否准确。
    猜你喜欢
    • 2014-07-30
    • 2017-02-22
    • 2014-04-03
    • 1970-01-01
    • 1970-01-01
    • 2017-09-07
    • 2016-07-08
    • 2016-05-12
    • 2013-07-12
    相关资源
    最近更新 更多