Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 3714  / 3 Years ago, tue, july 6, 2021, 4:56:39

I wan to use my Dropbox/Web directory as the server directory for LAMP. I cahnged /etc/apache2/sites-available/default



DocumentRoot /home/me/Dropbox/Web #changed from /etc/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/me/Dropbox/Web/> #changed from /etc/www
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>


And now I get



Forbidden

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

Apache/2.2.22 (Ubuntu) Server at localhost Port 80

More From » 12.04

 Answers
5

www-data, the group/user Apache runs is not allowed to read in your home directory.



You can use regular permissions to change that as gertvdijk explained in its answer.



I would consider using acl instead of regular permissions, allowing to add permission to apache instead of replacing the group in home directory or making the directory world readable.



For that, you need to install acl:



sudo apt-get install acl


You can use man setfacl to have more info.



To add permissions to apache:



sudo setfacl -m d:g:www-data:X,g:www-data:X /home/me
sudo setfacl -m d:g:www-data:X,g:www-data:X /home/me/Dropbox
sudo setfacl -Rm d:g:www-data:rX,g:www-data:rX /home/me/Dropbox/Web


1st and 2nd commands will allow Apache (www-data) to change directory only through the path (without allowing other subdirectories) in your home. They are probably not needed if you are using default config but if you already changed permissions (or will change in the future) to disalow other users to read in your home, they are needed.



The 3rd one is the command that will allow Apache to read and change directories in Dropbox/web and sub-directories).



Obs: uppercase X will act only on directories instead of lowercase x that would act on both files and directories (this way apache user is only able to change directories, not executing files).


[#33546] Wednesday, July 7, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hentor

Total Points: 482
Total Questions: 104
Total Answers: 111

Location: South Korea
Member since Sun, Dec 25, 2022
1 Year ago
;