[英]Changing root directory in apache2 is giving 403 Forbidden error
尽管这里有很多类似的问题,但是我无法从中解决我的问题。 我已经在ubuntu(14.04)
安装了Apache/2.4.7 (Ubuntu)
ubuntu(14.04)
。 我已经更改了两个配置文件,将apache
的默认DocumentRoot
更改为/var/www
到/home/name/www
。 我更改的文件是/etc/apache2/apache2.conf
和/etc/apache2/sites-available/000-default.conf
。 在apache2.conf
我把
<Directory /home/name/www>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
在000-default.conf
我进行了更改,
DocumentRoot /home/name/www
我的/home/name/www
文件具有必要的权限。
drwxr-xr-x 3 www-data www-data www
但是,当我尝试从浏览器访问localhost
,我收到You don't have permission to access / on this server.
错误。 我错过了什么?
为了将默认的apache
根目录从/var/www
更改为/home/<username>/www
以下更改对我有效。 我这样编辑了etc / apache2 / apache2.conf文件的以下值。 在编辑文件之前,最好保留原始文件的备份。
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /home/<username>/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
然后,我更改了/etc/apache2/sites-available/000-default.conf文件的DocumentRoot
。
DocumentRoot /home/<username>/www
之后,重新启动apache服务器,
sudo service apache2 restart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.