403 Forbidden on lamp-server vhost

Daniel Toebe asked:

This is on my dev machine which is running Linux mint 16 (which is based on Ubuntu 13.10). I installed lamp via:

apt install lamp-server^

and am running Apache 2.4.6

Upon installing lamp I created an info.php file to run phpinfo(); in /var/www, and of course that worked fine. On my dev machine I like to create a ~/public_html in my users home folder. Inside there I create my vhosts folders.

then I gave the public_html folder to the www-data user:group added myuser to the www-data group, and gave users and groups rwx access with:

chmod -R 775 /home/myuser/public_html

now my public_html and children look like

drwxrwxr-x    5 www-data www-data  4096 Apr  1 12:10 public_html

now I created a /etc/apache2/sites-available/example.local.conf

<VirtualHost *:80>
    ServerName example.local
    DocumentRoot "/home/myuser/public_html/example.local.d"
    <Directory "/home/myuser/public_html/example.local.d">
            Options Includes FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

Then ran:

a2ensite example.local.conf
service apache2 reload // I've also service apache2 restart

then going to example.local I get a 403

I have tried a few different configurations for the vhost .conf file. In one I specified error logs

in the error.log I got:

[Tue Apr 01 12:13:06.375465 2014] [core:error] [pid 14208] (13)Permission denied:          [client 127.0.0.1:45489] AH00035: access to / denied (filesystem path     '/home/myuser/public_html') because search permissions are missing on a component of the path

[Tue Apr 01 12:13:06.600588 2014] [core:error] [pid 14208] (13)Permission denied: [client 127.0.0.1:45489] AH00035: access to /favicon.ico denied (filesystem path '/home/myuser/public_html') because search permissions are missing on a component of the path

How do I fix this?

P.S. This is going to be for developing a Drupal site if that helps with the answer.

My answer:


Your error message says:

because search permissions are missing on a component of the path

which means that a parent directory does not allow Apache to traverse it.

To find out what directory that is, use ls -ld on each directory in turn, or (Linux-only) use namei:

namei -l /home/myuser/public_html

You will then be shown the permissions and be able to find the directory with the permissions that need to be corrected. For example, you may see:

f: /home/myuser/public_html
drwxr-xr-x root   root   /
drwxr-xr-x root   root   home
drwx------ myuser myuser myuser
drwxr-xr-x myuser myuser public_html

In this case, /home/myuser does not allow directory traversal for anyone other than the user. So it would be corrected with:

chmod +x /home/myuser

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.