Apache服务器添加网站目录不在根目录的情况

Apache原本根目录:

/var/www

需要添加的新的Apache网站目录

/home/***

在Apache服务器虚拟配置下添加一个站点

<VirtualHost *:80>
    ServerName  www.***.com
    DocumentRoot "/home/***/"
    ErrorLog "/var/log/xxx.log"
    CustomLog "/var/log/xxx.log" common
</VirtualHost>    

保存重启Apache服务器,然后访问网站会发现如下错误

You don't have permission to access / on this server.

该错误原因是没有访问权限。。。

只需要在apache.conf下配置即可

<Directory /home/***/>
    Options Indexes FollowSymLinks
    AllowOverride ALL
    Require all granted
</Directory>

然后重启Apache服务器再访问网站及正常了。

原文地址:https://www.cnblogs.com/liscookie/p/4362118.html