Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 添加virtualhost后出现错误403_Apache - Fatal编程技术网

Apache 添加virtualhost后出现错误403

Apache 添加virtualhost后出现错误403,apache,Apache,这是我在/etc/httpd/conf/extra/httpd-vhosts.conf中的指令 <VirtualHost *:80> ServerName sub.somedomain.com DocumentRoot "srv/http/subdir" <Directory '/srv/http/subdir'> Options -Indexes +FollowSymlinks

这是我在/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>

ServerName sub.somedomain.com
DocumentRoot“srv/http/subdir”
选项-索引+FollowSymlinks
允许超越所有
命令允许,拒绝
通融
要求所有授权

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

您不需要options指令,因为您已经声明了文档根目录。我会把整个街区移走。不过,您需要声明默认文件。比如:
DirectoryIndex.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


您可以取消对错误日志部分的注释,并将其设置到您自己的位置。您可以通过实际命名您试图在url中点击的文件名来确定上述内容是否准确。