Apache 添加virtualhost后出现错误403
这是我在/etc/httpd/conf/extra/httpd-vhosts.conf中的指令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
<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中点击的文件名来确定上述内容是否准确。