Cannot edit group-owned files as user belonging to that group
You're setting 644 which is group read, not write!
sudo chown -R www-data:www-data /srv/www
sudo chmod -R g+w /srv/www
I had a similar problem running 16.04 on DigitalOcean. Here are the steps I followed:
Give write access to the group associated with a file under
/var/www/html
sudo find /srv/www/ -type f -exec sudo chmod 664 {} \;
Add
myuser
to thewww-data
group:sudo adduser myuser www-data
Confirm permissions, e.g.:
ls -la /var/www/html/wp-content/themes/responsive/style.css
gives
-rw-rw-r-- www-data www-data 3892 Jan 1 2017 style.css
Confirm group membership:
id myuser
givesuid=1000(myuser) gid=1000(myuser) groups=1000(myuser),33(www-data),110*lxd)
However, when I then tried to update style.css
without sudo
with my myuser
account, I got a permission denied
error.
Solution
I had to log out and log back in again from all sessions that were logged in as myuser
before the new permissions began to take effect. Not sure why, but hope this may help anyone else in a similar situation.