Saturday, October 17, 2015

linux - How can I know what www-data can do on my /var/www folder?



When I run ls -l on the www folder and everything that's inside, I see that root:root are the owner/group



When I run ps aux | grep apache2, I get the first process owned by root (I assume this is normal, but why is it owned by root and not www-data?) and I get 6 other processes owned by www-data.




Now, since the ls -l /var/www shows -rw-r--r--, it should mean that www-data has no write privileges since it's in "world" (and also not in the "root" group).



But if, in my web application, users can upload images, I imagine there should be a folder inside /www called "uploadedpics/" on which www-data would have write privileges, is that right?



So if user and group are root:root for the /www folder, how can I create a subdirectory in which www-data can write?



Thanks a lot for your help


Answer



The first Apache process being owned by root is an artifact of earlier days of computing on Linux where the root user was the only account which can bind to ports under 1024. The progresses that serve content run under the www user.




To allow write access to a folder change the owner or group to the www user and chmod 775 or similar.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...