2014-05-06 76 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