2014-05-06 71 views
2

虽然这里有很多类似的问题,但我无法解决他们的问题。 我在我的ubuntu(14.04)中安装了Apache/2.4.7 (Ubuntu)。我已经更改了两个配置文件来更改默认DocumentRootapache这是/var/www/home/name/www。我改变的文件是/etc/apache2/apache2.conf/etc/apache2/sites-available/000-default.conf。在apache2.conf我把更改apache2中的根目录是403禁止错误

<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.错误。我错过了什么?

+0

你重装阿帕奇? 'sudo service apache2 restart' – Fernando

+0

@Fernando是的,但也有一些其他的变化。我忘了解答我的答案。我马上就会讲。 –

回答

2

将以下更改工作后,将默认根目录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 
+0

在Ubuntu 14.04上使用apache 2.4.7做了同样的事情,不起作用:禁止访问 – Louis