After following guides to install my preferred web server for the Raspberry Pi, Lighttpd, I always seem to have a problem with permissions when modifying files in or under /var/www/ folder.
In the guides that have I have gone through you do go through adding the Pi user to the www-data folder and what not but you will still get Permission Denied error when trying to add/remove/modify/create files when SFTP’ing in.
I had found this and that from here and there, butchering 10 commands every time I hit the problem, i just wanted it to work, however.
So I have come to install a new instance of Lighttpd on a test RPi, again I have hit the permission issues, cant find that bit of paper with my some what of a solution written down, a quick google…
I was just going to start going through bookmarks to find these random commands that is whatever way get what I want done when I spotted this post I hadn’t seen before by pksato » Fri Jul 22, 2016 over on the raspberrypi.org/forums. This was exactly my issue and from what I understand this seems to resolve this issues i have been having in a short swift way.
Here is the link to the original page, post 3;
On normal situation, http daemon run as some user and group, www-data on debian (raspbian).
Standard html files are stored on /var/www/, owned by root:root, with permissive permission, all can read, but only root can write.
To ordinary user write to /var/www need to takeover it. Supposed the use is pi.
sudo chown -R pi:www-data /var/www
Also, need to set user and group permission:
sudo chmod u+rxw,g+rx-w,o-rwx /var/www
Now, /var/www can be read,write and chdir by user pi, group www-data can chdir and read. Other not have access.