Apache 2: Symbolic link not allowed or link target not accessible








While I was setting up Apache 2 on Ubuntu Linux, I want to change the default DocumentRoot from /var/www to /store/services/www, my site configuration is below:
        DocumentRoot /store/services/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /store/services/www/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
When accessing the web page, got permission error. Also see error in /var/log/apache2/error.log:
[Sat Dec 08 22:40:41 2012] [error] [client 192.168.20.11] Symbolic link not allowed or link target not accessible: /var/www

The problem:

Struggle for a few minutes, found what the problem is: Apache needs read & execute permissions to not only the target directory, but it needs rx permissions to all the way through until reaching the target directory. For example, in the configuration above, we have the target directory /store/services/www, we need to set the permission of all the parent folders so that the apache user(e.g www-data) have at least read & execute permission.

The solution:

sudo chmod 755 /store
sudo chmod 755 /store/services
sudo chown -R www-data:www-data /store/services/www



1 comment: