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:

  1. Give write access to the group associated with a file under /var/www/html

    sudo find /srv/www/ -type f -exec sudo chmod 664 {} \;
    
  2. Add myuser to the www-data group:

    sudo adduser myuser www-data
    
  3. 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
    
  4. Confirm group membership: id myuser gives

    uid=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.