简体   繁体   English

添加虚拟主机后出现错误403

[英]Error 403 after adding virtualhost

This is my directive inside /etc/httpd/conf/extra/httpd-vhosts.conf 这是我在/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>

When i try to access any file inside subdir, i get 403 access denied error. 当我尝试访问subdir内的任何文件时,出现403访问被拒绝错误。 I tred restarting apache, i changed ownership of all files inside /srv/http to http:http too. 我尝试重新启动apache,也将/ srv / http中所有文件的所有权也更改为http:http。

You don't need the options directive since you've already declared a document root. 因为已经声明了文档根目录,所以不需要options指令。 I would remove that whole block. 我会删除整个块。 You need to declare default files though. 但是,您需要声明默认文件。 Like: 喜欢:
DirectoryIndex index.html index.php default.html DirectoryIndex index.html index.php default.html

Also, check your site logs or apache logs to see a more detailed error. 另外,请检查您的站点日志或apache日志以查看更详细的错误。

Here's an example of one of my virtual directories: 这是我的一个虚拟目录的示例:

    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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM