Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache symlinks give 403 Forbidden

Tags:

php

apache

I have some projects in /home/novito/Projects that I want Apache to be able to serve.

I have done the following:

cd /var/www
sudo ln -s /home/novito/Projects/testphp testphp

When I visit localhost/testphp/index.php, I get a

You don't have permission to access /testphp/prova.php on this server.

I have tried doing the following:

cd /home/novito/Projects
sudo chmod 755 testphp

But I still have the same problem. When doing ls -la, I see the following info for testphp directory:

drwxr-xr-x  2 novito novito

What am I doing wrong?

like image 691
Nobita Avatar asked Nov 02 '22 06:11

Nobita


1 Answers

Currently, you just tested the permission for testphp directory.

The complete path has to be executable by Apache. So you have to do this:

$ cd /
$ sudo chmod o+x home
$ sudo chmod o+x home/novito
$ sudo chmod o+x home/novito/Projects
$ sudo chmod o+x home/novito/Projects/testphp

Or in a single line:

$ sudo chmod o+x /home /home/novito /home/novito/Projects /home/novito/Projects/testphp

This will give Apache (and everybody else) the right permissions.

A more comprehensive answer can be found here on AskUbuntu. Worth reading.

like image 141
Jivan Avatar answered Nov 11 '22 12:11

Jivan