[英]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.